|
Boost Users : |
Subject: Re: [Boost-users] boost::transform_iterator, boost::array::iterator and category
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-04-03 17:40:20
AMDG
Hicham Mouline wrote:
> typedef transform_iterator< UnaryFunction, ... > iteratorIntoFirst;
>
>
> struct UnaryFunction: public std::unary_function< pair<double, double>,
> double> {
> double operator()( const pair<double, double>& e ) const
> {
> return e.first;
> }
> }
>
> However on asserting the category is still random access, boost static
> assert fails:
> <snip>
>
Try returning a reference const double& instead of double.
struct UnaryFunction {
typedef const double& result_type;
const double& operator()( const pair<double, double>& e ) const
{
return e.first;
}
};
Random access iterators must return an lvalue.
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net