Picon

Re: lifetime of ranges vs. iterators

On Fri, Aug 29, 2008 at 3:13 PM, Arno Schödl <aschoedl <at> think-cell.com> wrote:
> I have seen your | operator. It is o.k. for unary things, like rng | filter( predicate ), but for binary
things, it is a bit weird:
>
> rngA | difference(rngB)
>
> I find the alternatives clearer: rngA - rngB would be nice (but requires concept checking), or
difference( rngA, rngB ).

What about Infix a-la FC++?

  (rngA ^difference^ rngB)

I love the syntax, but maybe this is too much operator abuse.

>
> But regardless of notation, doesn't this suffer from the same problem that these
> objects are temporaries?

I'm still missing something: where is the problem in:

vector<int> vecnA;
vector<int> vecnB;

DoSomethingWithRangeThatStoresIterators( difference_range< int, int >
diffrng( vecnA, vecnB ) );

This works, as long as the range doesn't escape from DSWRTSI, or a copy is made.

[of course a make_difference_range would make the code much cleaner]

--

-- 
gpd
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Gmane