Boost logo

Boost :

Subject: Re: [boost] [variant] Please vote for behavior
From: Neil Groves (neil_at_[hidden])
Date: 2013-01-25 15:50:37


>
> I think variant after move is like int without initialization:
> int i;
> cout << i; // don't do this
> If the fact, that moved-from objects are only good for destruction or
> assignment-to is accepted, then invariants for moved-from objects are
> allowed to be violated.
>
>
I completely agree with the notion that a moved-from object simply should
not be used in any manner. It is interestingly divergent from the typical
Design by Contract idiom. It is much more usual, in my experience for the
class-invariants to hold up to and including entry to the destructor.

It seems that this divergence is of little importance to users of the
language since we are not explicitly interested in calling the destructor.
If I understand correctly the standard is divergent to allow sensible
compiler implementations of clean-up code for moved-from objects.

Hence I am in agreement with your sentiment, but wanted to point out that
this is unusual use of the DbC rules. Unusual in this case is not meant to
imply bad; it is rather interesting.

> Kris
>
>
Regards,
Neil Groves


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