Fixed C++11 implementation of map's result_of::deref_data to return a

reference as expected.
This commit is contained in:
Joel de Guzman
2014-11-18 23:11:13 +08:00
parent 68b4683e95
commit 0f34b3a692
3 changed files with 18 additions and 8 deletions

View File

@ -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]

View File

@ -83,8 +83,10 @@ namespace boost { namespace fusion
{
typedef typename Iterator::sequence sequence;
typedef typename Iterator::index index;
typedef
typedef typename
add_reference<
decltype(boost::declval<sequence>().get(index()).second)
>::type
type;
BOOST_FUSION_GPU_ENABLED

View File

@ -140,6 +140,15 @@ main()
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();
}