我收到以下代码的警告,如果我从变体中删除 boost::blank 则会消失:
namespace DB
{
struct Value{};
struct Container{};
}
typedef boost::variant <boost::blank, DB::Value, DB::Container> CommandData;
struct Command {
explicit Command(CommandData& _data): data(_data){
}
CommandData data;
};
int main()
{
CommandData commandData;
Command command(commandData);
return 0;
}
这是什么问题?
这是警告:
1>: warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
1> c:\boost_1_49_0\boost\variant\variant.hpp(1224) : while compiling class template member function 'boost::variant<T0_,T1,T2>::variant(void)'
1> with
1> [
1> T0_=boost::blank,
1> T1=DB::Value,
1> T2=DB::Container
1> ]
1> c:\code.h(38) : see reference to class template instantiation 'boost::variant<T0_,T1,T2>' being compiled
1> with
1> [
1> T0_=boost::blank,
1> T1=DB::Value,
1> T2=DB::Container
1> ]