Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-09-16 14:19:19

"Peter Dimov" <pdimov_at_[hidden]> writes:

> 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.

Good point. We should use boost::optional here. Patches welcomed!

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at