Boost logo

Boost Users :

From: Nicola (nvitacolonna_at_[hidden])
Date: 2008-04-11 06:55:26


In article
<A194A82A1A084C4C8A29AD16E363B5F80100F620_at_WIN2003s325.its.local>,
 "Patrick Loney" <Patrick.Loney_at_[hidden]> wrote:

> I've had to comment out the line //*it = 8; but the rest works under VC8 and
> increments the value in the vector:
>
> struct f : public std::unary_function<int, int> {
> int operator()(int x) const { return ++x; } };
>
> typedef std::vector<int> vec_type;
> typedef boost::transform_iterator<f, vec_type::iterator> trans_iter_type;
>
>
> int _tmain(int argc, _TCHAR* argv[]) {
> vec_type V;
> V.push_back(4);
> trans_iter_type it(boost::make_transform_iterator(V.begin(),f()));
> std::cout << *it << std::endl;
> //*it = 8;
> std::cout << *it << std::endl;
> return 0;
> }

The above works for me as well. Adding the const qualifier has also
solved my original problem. So, operator() must be const qualified. Is
that documented somewhere or is it somehow inferrable?

Thank you,
Nicola


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