Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-11-19 19:20:42


Herve Bronnimann <hbr_at_[hidden]> writes:

> On Tue, Nov 19, 2002 at 10:35:00AM -0500, David Abrahams wrote:
>> > On Tuesday 19 November 2002 07:11, Herve Bronnimann wrote:
>> >> Dave, Jeremy: one iterator adaptor I needed often (and once again today)
>> >> is the projection on the first or second member of a pair. I could make
>> >> it using projection_iterator<> and select1st, except that select1st is
>> >> an std extension from SGI. I haven't found any other out-of-the-box way
>> >> to do this, did I miss something?
>> >
>> > Not as far as I can see.
>>
>> Can't you just use make_projection_iterator with bind(&pair<X,Y>::first) ?
>
> Would work fine for boost::compressed_pair, but not for std::pair,
> IIUC. In one, first is a member function, but in the other it's
> just a public data member.

bind supports data members.

> Even assuming it works, would it inline the access to first
> properly?

No, it would "properly" store the data member pointer and indirect
through that ;-)

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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