forked from boostorg/optional
Use BOOST_EXPLICIT_OPERATOR_BOOL for optional
I often have the problem that when I change a std::wstring to boost::optional<std::wstring> and the variable is used as a parameter with Boost.Format, the result silently changes from the string contents to "1". This change prevents implicit conversion to bool if the compiler supports explicit conversion operators.
This commit is contained in:
committed by
Andrzej Krzemienski
parent
b4738ac07e
commit
c7cf80e5df
@ -1086,8 +1086,8 @@ namespace optional_swap_test
|
||||
//
|
||||
void swap(boost::optional<class_whose_explicit_ctor_should_be_used> & x, boost::optional<class_whose_explicit_ctor_should_be_used> & y)
|
||||
{
|
||||
bool hasX = x;
|
||||
bool hasY = y;
|
||||
bool hasX(x);
|
||||
bool hasY(y);
|
||||
|
||||
if ( !hasX && !hasY )
|
||||
return;
|
||||
|
Reference in New Issue
Block a user