Boost logo

Boost Users :

Subject: [Boost-users] [optional] operator <<
From: Igor R (boost.lists_at_[hidden])
Date: 2009-02-19 06:45:15


Hello,

I've just noticed that the following code might be missleading:

boost::optional<int> opt;
opt = 0;
std::cout << opt;

If boost/optional/optional_io.hpp is not included, the above code outputs
"1" - because boost::optional is implicitly convertible to bool.
Maybe it's worth either including boost/optional/optional_io.hpp in
boost/optional.hpp or making some trick to generate compiler error if
operator <<() used and optional_io.hpp is not included?



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