id summary reporter owner description type status milestone component version severity resolution keywords cc
4969 transform_iterator won't work with non-const operator() call for function object zhuo.qiang@… jeffrey.hellrung "transform_iterator declare it's copied function object as:
{{{#!c++
UnaryFunc m_f;
}}}
And it's dereference function as:
{{{#!c++
typename super_t::reference dereference() const
{ return m_f(*this->base()); }
}}}
which makes it impossible to cooperate with function object with non-const operator() overloading, and and it will also make transformed adaptor in boost::range not work:
{{{#!c++
struct Fun
{
typedef bool result_type;
bool operator()(int a)
{
return a != 1;
}
};
Fun f;
boost::find(all|boost::adaptors::transformed(f), true);
}}}
A boost::ref won't work here since the result has no result_type defined
And the only solution would be using a boost::function to hold the original function object, however, doing so will give unnecessary run time cost.
I suggest change the UnaryFunc m_f; definition to mutable, so that it will work with non-const functor.
{{{#!c++
UnaryFunc mutable m_f;
}}}
" Bugs new To Be Determined iterator Boost 1.45.0 Regression