Tell me more ×  I have a boost::variant in my program and I want
to check if the variant itself is initialized and also if there
is a value contained in one of it's types.  I've tried empty()
on the variant, but that doesn't seem to work. Neither does
checking against NULL.  Does anybody know how to check for this?
EDIT: Ok, It seems it will never be empty, but there will not
always be a value in it's contained types, so how do I check for
a no-value situation?  share|improve this question Please
forgive me if I misunderstand the question, however, according
to Never Empty Guarantee, boost::variant seems not to get
empty... –  Ise Wisteria Mar 15 '11 at 13:31 None of the
existing answers are good enough? what is missing? –  lurscher
Jun 28 at 5:25 add comment  4 Answers  up vote 5 down vote
accepted  A boost::variant is always initialized.  If you did
not initalized it explicitly, the first item was constructed
using its default constructor:  struct Foo {}; struct Bar {};
struct Visitor: boost::static_visit