
4 Aug
2008
4 Aug
'08
5:02 p.m.
On 08/04/08 09:00, Mathias Gaunard wrote:
Emil Dotchevski wrote:
Do I read correctly that in an attempt to assign one variant object to another, the left-hand object _might_ silently change its type? If an exception is thrown during assignment to a boost::variant<T0, T1, ...>, and one of the Ti is nothrow default-constructible, then the [snip] Then you should use tags, and not ugly hacks. Tags? Do you mean something like:
template<unsigned Tag, typename Type> struct tagged_type { Type a_t; }; boost::variant < tagged_type<0,T0> , tagged_type<1,T1> ...
? In this way, even if T0==T1==...==Tn, the variant would still work but I guess the tagged_type CTOR would have to forward its CTOR args to the a_t.