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>
|
||||
|
||||
[heading Example]
|
||||
typedef __map__<__pair__<float,int&> > map;
|
||||
typedef __map__<__pair__<float, int&> > map;
|
||||
|
||||
int i(0);
|
||||
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>
|
||||
|
||||
[heading Example]
|
||||
typedef __map__<__pair__<float,int> > map;
|
||||
typedef __result_of_begin__<vec>::type first;
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<__result_of_deref_data__<first>::type, int&>));
|
||||
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));
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@ -83,8 +83,10 @@ namespace boost { namespace fusion
|
||||
{
|
||||
typedef typename Iterator::sequence sequence;
|
||||
typedef typename Iterator::index index;
|
||||
typedef
|
||||
decltype(boost::declval<sequence>().get(index()).second)
|
||||
typedef typename
|
||||
add_reference<
|
||||
decltype(boost::declval<sequence>().get(index()).second)
|
||||
>::type
|
||||
type;
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
|
@ -139,6 +139,15 @@ main()
|
||||
pair<int, copy_all> 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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user