According to Boost doc for boost::variant
:
"Never-Empty" Guarantee
All instances v of type variant guarantee that v has constructed content of one of the types Ti, even if an operation on v has previously failed.
Looking in "boost/variant.hpp", in particular variant's default constructor, you see:
// boost/variant.hpp: 1383
variant()
{
// NOTE TO USER :
// Compile error from here indicates that the first bound
// type is not default-constructible, and so variant cannot
// support its own default-construction.
//
new( storage_.address() ) internal_T0();
indicate_which(0); // zero is the index of the first bounded type
}
For the variant types being bounded, the first type gets default-init. That means for your req
type, A *
gets zero-init. That also means B *
is zero-init since variants can be viewed as a union.