Fix const/non-const interop for transform_iterator

[SVN r21172]
This commit is contained in:
Dave Abrahams
2003-12-07 20:33:18 +00:00
parent 296ce3aa89
commit f14701232a
3 changed files with 31 additions and 18 deletions

View File

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