mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-19 23:32:17 +02:00
Fixed C++11 implementation of map's result_of::deref_data to return a
reference as expected.
This commit is contained in:
@ -513,7 +513,7 @@ Deferences the data property associated with the element referenced by an associ
|
|||||||
#include <boost/fusion/include/deref_data.hpp>
|
#include <boost/fusion/include/deref_data.hpp>
|
||||||
|
|
||||||
[heading Example]
|
[heading Example]
|
||||||
typedef __map__<__pair__<float,int&> > map;
|
typedef __map__<__pair__<float, int&> > map;
|
||||||
|
|
||||||
int i(0);
|
int i(0);
|
||||||
map m(1.0f,i);
|
map m(1.0f,i);
|
||||||
@ -1070,14 +1070,13 @@ Returns the type that will be returned by dereferencing the data property refere
|
|||||||
#include <boost/fusion/include/deref_data.hpp>
|
#include <boost/fusion/include/deref_data.hpp>
|
||||||
|
|
||||||
[heading Example]
|
[heading Example]
|
||||||
typedef __map__<__pair__<float,int> > map;
|
typedef map<pair<float, int> > map_type;
|
||||||
typedef __result_of_begin__<vec>::type first;
|
typedef boost::fusion::result_of::begin<map_type>::type i_type;
|
||||||
|
typedef boost::fusion::result_of::deref_data<i_type>::type r_type;
|
||||||
BOOST_MPL_ASSERT((boost::is_same<__result_of_deref_data__<first>::type, int&>));
|
BOOST_STATIC_ASSERT((boost::is_same<r_type, int&>::value));
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -83,8 +83,10 @@ 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
|
typedef typename
|
||||||
decltype(boost::declval<sequence>().get(index()).second)
|
add_reference<
|
||||||
|
decltype(boost::declval<sequence>().get(index()).second)
|
||||||
|
>::type
|
||||||
type;
|
type;
|
||||||
|
|
||||||
BOOST_FUSION_GPU_ENABLED
|
BOOST_FUSION_GPU_ENABLED
|
||||||
|
@ -139,6 +139,15 @@ main()
|
|||||||
pair<int, copy_all> p1;
|
pair<int, copy_all> p1;
|
||||||
pair<int, copy_all> p2 = p1;
|
pair<int, copy_all> p2 = p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// compile test only
|
||||||
|
// make sure result_of::deref_data returns a reference
|
||||||
|
typedef map<pair<float, int> > 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&>::value));
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user