|
Boost : |
Subject: Re: [boost] [range] adaptors vs. rvalue to lvalue& binding
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2012-03-23 16:28:31
Hello,
>
> - make adaptor expressions return const rvalues. The const rvalues will
> bind to T& arguments (where T is a template parameter) by deducing T
> to be const.
>
> - make even the const_iterators for such adaptors mutable (writable)
> iterators
>
> This accurately reflects the fact that such adaptors don't own their values.
If boost::sort is supposed to be chainable (which seems a good idea), then let's not start with adaptors. We already need a solution for
boost::sort( std::vector() );
If the solution is
template<typename Range>
boost::sort( Range && );
then in
boost::sort( boost::adaptors::reverse( std::vector() ) );
reverse should probably derive mutable iterators from mutable rvalues, so would have signature:
reverse( Range && );
So the policy is:
All range functions and adaptors take all ranges by &&, and range::iterator<rvalue>::type is mutable, in particular for adaptors. To chain from a function, return via std::forward<Range>.
Problem solved?
Arno
-- Dr. Arno Schödl | aschoedl_at_[hidden] Technical Director think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091 Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk