Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-09-16 12:29:48


Fredrik Blomqvist wrote:
> Hi
>
> Consider this example of mem_fn usage:
>
> struct X { int bar; };
> std::vector<X> vec;
> ....
> boost::make_transform_iterator(vec.begin(), boost::mem_fn(&X::bar));
>
> The above is, strictly speaking, _not_ a Random Access Traversal
> Iterator,
> or even a Forward Traversal Iterator, and would fail in otherwise
> concept conforming code (or in a potential concept-check).
>
> The problems lies in the function objects returned by boost::mem_fn
> and boost::bind not being default constructible, thus making the
> resulting iterator not default constructible which is required by the
> Forward Traversal concept.

No, the problem lies in (the current implementation of) transform_iterator.
It is not reasonable to require function objects to be default
constructible, because few of them are, and in fact, the documentation
places no such requirement on the function object.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk