Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-09-01 13:09:36


Brian McNamara <lorgon_at_[hidden]> wrote in message
news:20030831102933.A31012_at_helsinki.cc.gatech.edu...
> On Sun, Aug 31, 2003 at 12:34:39AM -0700, Mat Marcus wrote:
> [snipped]
>
> So, here's an idea for something completely new which maybe helps fit
> your requirements. I start with the motivating example:
>
> PossUninitVar<Iter> begin, end;
> tie( +begin, +end ) = out_edges(v,g);
> for( Iter i = ~begin; i != ~end; ++i ) ...
>
> (Effectively operator~() fetches the value (or asserts if there is none),
> whereas operator+() returns a reference to the yet-nonexistent value so
> it can be filled in by someone else.)
>
>
My original submission used a proxy operator*() to allow assignment in
the same way you do here with operator+().
During the review I removed it because if expressions (*opt)
implied possibly undefined behaviour when used a rvalues so should
when used as lvalues. Yet assignment is always defined so
be changed it by reset().
It didn't ocurred to me though to use _another_ operator
instead, and so allow the definitely useful lvalue expressions.

Right now however, I'm inclined toward direct assignment,
ala variant, because the only problem with this is the
potential conceptual confusion (since this operation is always
defined), and I prefer to address this problem at the
documentation level.

Fernando Cacciola


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