Boost logo

Boost :

From: Fredrik Blomqvist (fredrik_blomqvist_at_[hidden])
Date: 2004-09-16 11:53:32


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.
http://boost.org/libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators
(The problem is even more pronounced if using the "old" Iterator Concepts.)

I found an old (2002) mail by David Abrahams where he also noted the
problem: http://lists.boost.org/MailArchives/boost/msg30420.php
But it didn't seem to have resulted in any change of the codebase.

I think use-cases similar to the one above are good motivation and hope this
could be considered an acceptable improvement.

Regards
// Fredrik Blomqvist

P.S. I realize it is very close to the branch for release and don't expect
this to be added before that.


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