fix static_variant to/from variant

This commit is contained in:
Daniel Larimer 2015-03-05 09:54:33 -05:00
parent 3a120c0f7f
commit 73c2c1de90
3 changed files with 6 additions and 7 deletions

View file

@ -348,7 +348,7 @@ struct visitor {
typedef void result_type;
template<typename T> void operator()( T& v )const
{
to_variant( var, v );
from_variant( var, v );
}
};
@ -364,9 +364,8 @@ struct visitor {
template<typename... T> void from_variant( const fc::variant& v, fc::static_variant<T...>& 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]) );
}

View file

@ -102,7 +102,7 @@ namespace fc {
}
uint64_t to_uint64( const fc::string& i )
{
{ try {
try
{
return boost::lexical_cast<uint64_t>(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)
{

View file

@ -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