forked from boostorg/iterator
Fix const/non-const interop for transform_iterator
[SVN r21172]
This commit is contained in:
@ -59,7 +59,18 @@ struct adaptable_mult_functor
|
||||
};
|
||||
|
||||
|
||||
struct const_select_first
|
||||
{
|
||||
typedef int const& result_type;
|
||||
|
||||
int const& operator()(std::pair<int, int>const& p) const
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
};
|
||||
|
||||
struct select_first
|
||||
: const_select_first // derivation to allow conversions
|
||||
{
|
||||
typedef int& result_type;
|
||||
|
||||
@ -79,16 +90,6 @@ struct select_second
|
||||
}
|
||||
};
|
||||
|
||||
struct const_select_first
|
||||
{
|
||||
typedef int const& result_type;
|
||||
|
||||
int const& operator()(std::pair<int, int>const& p) const
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
};
|
||||
|
||||
struct value_select_first
|
||||
{
|
||||
typedef int result_type;
|
||||
@ -237,8 +238,12 @@ main()
|
||||
boost::make_transform_iterator((pair_t*)values, const_select_first()), x[0]);
|
||||
|
||||
boost::non_const_lvalue_iterator_test(
|
||||
boost::make_transform_iterator((pair_t*)values, select_first()), x[0], 17);
|
||||
boost::make_transform_iterator((pair_t*)values, select_first()), x[0], 17);
|
||||
|
||||
boost::const_nonconst_iterator_test(
|
||||
++boost::make_transform_iterator((pair_t*)values, select_first())
|
||||
, boost::make_transform_iterator((pair_t*)values, const_select_first())
|
||||
);
|
||||
}
|
||||
|
||||
std::cout << "test successful " << std::endl;
|
||||
|
Reference in New Issue
Block a user