Merge branch 'master' of https://github.com/cryptonomex/fc
This commit is contained in:
commit
78552e83d6
1 changed files with 8 additions and 1 deletions
|
|
@ -431,7 +431,14 @@ bool variant::as_bool()const
|
||||||
switch( get_type() )
|
switch( get_type() )
|
||||||
{
|
{
|
||||||
case string_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:
|
case double_type:
|
||||||
return *reinterpret_cast<const double*>(this) != 0.0;
|
return *reinterpret_cast<const double*>(this) != 0.0;
|
||||||
case int64_type:
|
case int64_type:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue