reflect_util.hpp: Fix reflection, make propose_fee_change work as intended

This commit is contained in:
theoreticalbts 2015-10-14 10:09:31 -04:00
parent 546755484a
commit 9870b5db0a

View file

@ -53,16 +53,34 @@ struct static_variant_map_visitor
int which; int which;
}; };
template< typename StaticVariant >
struct from_which_visitor
{
typedef StaticVariant result_type;
template< typename Member > // Member is member of static_variant
result_type operator()( const Member& dummy )
{
Member result;
from_variant( v, result );
return result; // converted from StaticVariant to Result automatically due to return type
}
const variant& v;
from_which_visitor( const variant& _v ) : v(_v) {}
};
} // namespace impl } // namespace impl
template< typename T > template< typename T >
T from_which_variant( int which, const variant& v ) T from_which_variant( int which, const variant& v )
{ {
// Parse a variant for a known which() // Parse a variant for a known which()
T result; T dummy;
result.set_which( which ); dummy.set_which( which );
from_variant( v, result ); impl::from_which_visitor< T > vtor(v);
return result; return dummy.visit( vtor );
} }
template<typename T> template<typename T>