
16 May
2008
16 May
'08
6:32 p.m.
Can someone give me a hint about this. If I define a variant type boost::variant<double,std::string> var; and it will not compile if I do the following: int an_int(8); int* p_int(&an_int); var=p_int; std::cout << var.which() << std::endl; But if I define the type including bool: boost::variant<double,std::string,bool> var; the above code can compile and prints 2. It seems that when type bool is in the list, any pointer assigned to var will convert to a bool. The bad thing is that the compiler will not complain about it. Is there a way to prevent the assignment of a pointer type to a boost::variant variable? I am new to boost and I would be very appreciated if someone can help me on this. Yanbin Zhang