This commit is contained in:
Daniel Larimer 2016-02-01 18:29:56 -05:00
commit 78552e83d6

View file

@ -431,7 +431,14 @@ bool variant::as_bool()const
switch( get_type() )
{
case string_type:
return **reinterpret_cast<const const_string_ptr*>(this) == "true";
{
const string& s = **reinterpret_cast<const const_string_ptr*>(this);
if( s == "true" )
return true;
if( s == "false" )
return false;
FC_THROW_EXCEPTION( bad_cast_exception, "Cannot convert string to bool (only \"true\" or \"false\" can be converted)" );
}
case double_type:
return *reinterpret_cast<const double*>(this) != 0.0;
case int64_type: