[variant] Proposal of compile-time checked get for variant
[Note to moderator]
I am not surte if previous version of this message will really go
through, beacuase I was not yet subscribed to users list.
Should that be the case, please forgive me.
[End of note to moderator]
Dear all,
I have been doing a deep redesign of an old SW project, and in the
course of it I have changed a typical struct {enum;union;} to
boost:variant.
This design change has surfaced some problems of the original SW, as
there were lots of implicit/explicit casting when accesing the above
mentioned struct.
To detect and correct all this problems, I have found that boost::get
working on boost:variant is not enough, it will only give either a
null pointer or a bad_get exception when trying to access a variant
with the wrong type. Even in the cases that the wrong type is
unaccessible all the time, as it is not included in the variant list
of types. IMHO, this should be detected at compile-time, as it denotes
a design flaw, not a runtime access error.
To cover this cases, I suggest the following addition to variant
library, based on get definition:
namespace boost {
template
participants (1)
-
Zara