diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 8fbc100..46a96ca 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -348,7 +348,7 @@ struct visitor { typedef void result_type; template void operator()( T& v )const { - to_variant( var, v ); + from_variant( var, v ); } }; @@ -364,9 +364,8 @@ struct visitor { template void from_variant( const fc::variant& v, fc::static_variant& s ) { auto ar = v.get_array(); - if( ar.size() ) return; + if( ar.size() < 2 ) return; s.set_which( ar[0].as_uint64() ); - if( ar.size() < 1 ) return; s.visit( to_static_variant(ar[1]) ); } diff --git a/src/string.cpp b/src/string.cpp index 3850912..93b6b7a 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -102,7 +102,7 @@ namespace fc { } uint64_t to_uint64( const fc::string& i ) - { + { try { try { return boost::lexical_cast(i.c_str()); @@ -112,7 +112,7 @@ namespace fc { FC_THROW_EXCEPTION( parse_error_exception, "Couldn't parse uint64_t" ); } FC_RETHROW_EXCEPTIONS( warn, "${i} => uint64_t", ("i",i) ) - } + } FC_CAPTURE_AND_RETHROW( (i) ) } double to_double( const fc::string& i) { diff --git a/src/variant.cpp b/src/variant.cpp index 9df67da..c9a1f60 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -384,7 +384,7 @@ int64_t variant::as_int64()const } uint64_t variant::as_uint64()const -{ +{ try { switch( get_type() ) { case string_type: @@ -402,7 +402,7 @@ uint64_t variant::as_uint64()const default: FC_THROW_EXCEPTION( bad_cast_exception,"Invalid cast from ${type} to uint64", ("type",get_type())); } -} +} FC_CAPTURE_AND_RETHROW( (*this) ) } double variant::as_double()const