Boost logo

Boost :

From: Loïc Joly (loic.joly_at_[hidden])
Date: 2006-12-21 11:11:50


I resurect an old post :

David Abrahams a écrit :
> Simon Buchan <simon_at_[hidden]> writes:
>
>>>>The idea is to define a template class,
[...]
>>>>which overloads operator*() and operator->() to access the element named
>>>>"first" of the object returned by Iterator::operator*(). (With something
>>>>analagous for second_iterator_t.) A function named first_iterator()
>>>>provides a convenient creation function a-la std::make_pair().
[...]
> struct get_first
> {
> template <class T>
> typename T::first_type& operator()(T& x) const
> {
> return x.first;
> }
>
> template <class T>
> typename T::first_type const& operator()(T const& x) const
> {
> return x.first;
> }
> };
>
> // similar get_second
>
> transform_iterator<get_first, Iterator>

Hello,

I think this kind of adapter is quite usefull and of broad usage, and I
think it should be part of the iterators provided by default in the
Iterator library, just like indirect_iterator. Or at least put is as a
real life example of what can be done with transform_iterator.

Regards,

-- 
Loïc

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