Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-08-30 13:02:09

on Thursday 30 August 2001 10:18, you wrote:
> variant<T,empty> v ;
> implies that v can hold a value of type T or type empty (or void, if that
> would be possible).
> According to variant semantics, it should be possible to assign empty() to
> v.
> So the empty type isn't any special; it just some sort of type that variant
> can hold.
> optional<T> opt ;
> on the other hand, can only have type T. It dosen't have a second
> 'void/empty' type.
> In other words, you cannot 'uninitialize' opt, which would be equivalent to
> v = empty();

Sure you can:
  v = optional<T>();

> That is, I think that a variant which might have a 'void' type value isn't
> exactly the same as a value that might be uninitialized.

I think it is just a matter of definition. Having the current type of a
variant<T, void> be void can be considered equivalent to having an
uninitialized T value.


Boost list run by bdawes at, gregod at, cpdaniel at, john at