Boost logo

Boost Users :

From: Zhang, Yanbin (yanbin.zhang_at_[hidden])
Date: 2008-05-16 20:32:19


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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net