Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-04-12 19:50:51


"Brian McNamara" <lorgon_at_[hidden]> wrote in message
news:20040412152352.GA1822_at_gaia2.cc.gatech.edu...
[snip]
> What's an example use-case? I don't recall ever needing/wanting this.

My initial use-case was to use it in mutating container algorithms. Without
it
you would have to create a temporary, even though you didn't need it (and
hardcoding the return-type
is messy). So it would have been
optimal just to hand the result of function to new functions even though
they mutate, eg

vector<int> vec();

my_copy( my_sort( my_unique( vec() ) ), ostream_iterator<int>( cout ) );

instead of

vector<int> temp1( vec() );
vector<int> temp2( my_unique( temp1 ) );
my_copy( my_sort( temp2 ), .... )

br

Thorsten


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