|
Boost : |
From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2005-10-14 18:03:18
Just to add to the noise on the subject of rebinding references ;?)
I asked about the following example at the meeting, as I was concerned
that despite several 'regular' users of optional being in the room, the
only way anyone knew what it did was to compile the code and see the
result. That seems too subtle a semantic to me.
Once you learn it, it seems obvious so it is not a blocking issue for
me. But it did raise a concern:
int a = 13;
int &b = a;
int c = 42;
optional< int & > d = b;
d = c;
Should this code compile? c is an int not an int &?
Should it assign the value of c to a, so now a == 42?
Or does it rebind the optional reference to c?
In both compiling scenarios d == 42, so you need to remember to check a
to conclude the experiment.
For the curious, the current answer is option 3 - d rebinds a reference
to c.
I also think optional is fundamentally too useful to let it run into
the ground over such issues ;?)
-- AlisdairM
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk