|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-10-08 21:03:18
"brock" <brock.peabody_at_[hidden]> writes:
> ----- Original Message -----
> From: "E. Gladyshev" <egladysh_at_[hidden]>
>
> [...]
>
>> I realize it now.
>> I think that it is ok to have a singular variant.
>> It should be treated as unallocated memory
>> any access to it should generate an exception.
>
> The downside is that then all users of boost::variant have to test for this
> possible condition or be prepared for runtime failure where otherwise they
> could rely on the variant to contain one of the specified types. Rather
> than force this complexity on those who aren't concerned with the
> possibility of using the heap backup, those who want this behaviour can just
> specify boost::empty as on of the possible types of the variant. As Dave
> was saying you are in effect using boost::empty to specify the policy.
Note that it wouldn't just be forced on people who are willing to
accept heap allocation. It would also be forced on people who don't
want heap allocation, but know they are never going to assign a
*different* type into a variant once it's been initialized.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk