From 9870b5db0ab2ffb88525342c514087392a4b6098 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Wed, 14 Oct 2015 10:09:31 -0400 Subject: [PATCH] reflect_util.hpp: Fix reflection, make propose_fee_change work as intended --- .../include/graphene/wallet/reflect_util.hpp | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/reflect_util.hpp b/libraries/wallet/include/graphene/wallet/reflect_util.hpp index 962b0347..5fefd81e 100644 --- a/libraries/wallet/include/graphene/wallet/reflect_util.hpp +++ b/libraries/wallet/include/graphene/wallet/reflect_util.hpp @@ -53,16 +53,34 @@ struct static_variant_map_visitor 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 template< typename T > T from_which_variant( int which, const variant& v ) { // Parse a variant for a known which() - T result; - result.set_which( which ); - from_variant( v, result ); - return result; + T dummy; + dummy.set_which( which ); + impl::from_which_visitor< T > vtor(v); + return dummy.visit( vtor ); } template