mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-18 23:02:14 +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/mpl/minus.hpp>
|
||||
#include <boost/mpl/equal_to.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
@ -83,11 +86,18 @@ namespace boost { namespace fusion
|
||||
{
|
||||
typedef typename Iterator::sequence sequence;
|
||||
typedef typename Iterator::index index;
|
||||
|
||||
typedef decltype(boost::declval<sequence>().get(index()).second) second_type_;
|
||||
|
||||
typedef typename
|
||||
add_reference<
|
||||
decltype(boost::declval<sequence>().get(index()).second)
|
||||
mpl::if_<
|
||||
is_const<sequence>
|
||||
, typename add_const<second_type_>::type
|
||||
, second_type_
|
||||
>::type
|
||||
type;
|
||||
second_type;
|
||||
|
||||
typedef typename add_reference<second_type>::type type;
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
static type
|
||||
|
@ -148,6 +148,15 @@ main()
|
||||
typedef boost::fusion::result_of::deref_data<i_type>::type r_type;
|
||||
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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user