mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-18 14:52:13 +02:00
Const correctness fix for result_of::deref_data
This commit is contained in:
@ -12,7 +12,10 @@
|
|||||||
#include <boost/fusion/iterator/iterator_facade.hpp>
|
#include <boost/fusion/iterator/iterator_facade.hpp>
|
||||||
#include <boost/mpl/minus.hpp>
|
#include <boost/mpl/minus.hpp>
|
||||||
#include <boost/mpl/equal_to.hpp>
|
#include <boost/mpl/equal_to.hpp>
|
||||||
|
#include <boost/mpl/if.hpp>
|
||||||
#include <boost/utility/declval.hpp>
|
#include <boost/utility/declval.hpp>
|
||||||
|
#include <boost/type_traits/is_const.hpp>
|
||||||
|
#include <boost/type_traits/add_const.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
@ -83,11 +86,18 @@ namespace boost { namespace fusion
|
|||||||
{
|
{
|
||||||
typedef typename Iterator::sequence sequence;
|
typedef typename Iterator::sequence sequence;
|
||||||
typedef typename Iterator::index index;
|
typedef typename Iterator::index index;
|
||||||
|
|
||||||
|
typedef decltype(boost::declval<sequence>().get(index()).second) second_type_;
|
||||||
|
|
||||||
typedef typename
|
typedef typename
|
||||||
add_reference<
|
mpl::if_<
|
||||||
decltype(boost::declval<sequence>().get(index()).second)
|
is_const<sequence>
|
||||||
|
, typename add_const<second_type_>::type
|
||||||
|
, second_type_
|
||||||
>::type
|
>::type
|
||||||
type;
|
second_type;
|
||||||
|
|
||||||
|
typedef typename add_reference<second_type>::type type;
|
||||||
|
|
||||||
BOOST_FUSION_GPU_ENABLED
|
BOOST_FUSION_GPU_ENABLED
|
||||||
static type
|
static type
|
||||||
|
@ -149,6 +149,15 @@ main()
|
|||||||
BOOST_STATIC_ASSERT((boost::is_same<r_type, int&>::value));
|
BOOST_STATIC_ASSERT((boost::is_same<r_type, int&>::value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// compile test only
|
||||||
|
// make sure result_of::deref_data is const correct
|
||||||
|
typedef map<pair<float, int> > const map_type;
|
||||||
|
typedef boost::fusion::result_of::begin<map_type>::type i_type;
|
||||||
|
typedef boost::fusion::result_of::deref_data<i_type>::type r_type;
|
||||||
|
BOOST_STATIC_ASSERT((boost::is_same<r_type, int const&>::value));
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user