Merge master into bitshares
This commit is contained in:
commit
66c18c6932
1 changed files with 22 additions and 4 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue