Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range] Adaptors
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-01-05 12:13:23


At Wed, 5 Jan 2011 16:05:56 +0000,
Robert Jones wrote:
>
> I might be asking for the impossible here, but given the lovely adaptor
> syntax, eg
>
> std::vector<int> vec;
> boost::copy( vec | boost::adaptors::reversed
> | boost::adaptors::uniqued,
> std::ostream_iterator<int>(std::cout) );
>
>
> I notice it still uses the function call notation in the outermost
> operation( boost::copy() ),
> can it be written to eliminate function call syntax completely, say
> something like
>
> vec | boost::adaptors::reversed | boost::adaptors::uniqued |
> boost::adaptors::copy( std::ostream_iterator<int>(std::cout) );
>
> or even
>
> vec | boost::adaptors::reversed | boost::adaptors::uniqued |
> std::ostream_iterator<int>(std::cout);

It could be done, but it might not make much sense. The boost
adaptors are essentially lazy sequence transformations, but the copy
operation you're asking for has a completely different nature: it's
eager. If you still like that syntax, though, you could write a
suitable copy function of your own in about 40 lines that would do the
same job.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net