FC Updates from BitShares and myself #21
2 changed files with 14 additions and 8 deletions
|
|
@ -146,21 +146,27 @@ namespace fc {
|
|||
return f();
|
||||
}
|
||||
|
||||
template<typename R, typename Signature, typename ... Args>
|
||||
R call_generic( const std::function<R(std::function<Signature>,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||
template<typename R, typename Signature, typename ... Args,
|
||||
typename std::enable_if<std::is_function<Signature>::value,Signature>::type* = nullptr>
|
||||
R call_generic( const std::function<R(std::function<Signature>,Args...)>& f,
|
||||
variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||
{
|
||||
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
||||
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||
detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>(1) );
|
||||
return call_generic<R,Args...>( this->bind_first_arg<R,std::function<Signature>,Args...>( f, std::function<Signature>(arg0) ), a0+1, e, max_depth - 1 );
|
||||
return call_generic<R,Args...>( this->bind_first_arg<R,std::function<Signature>,Args...>( f,
|
||||
std::function<Signature>(arg0) ), a0+1, e, max_depth - 1 );
|
||||
}
|
||||
template<typename R, typename Signature, typename ... Args>
|
||||
R call_generic( const std::function<R(const std::function<Signature>&,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||
template<typename R, typename Signature, typename ... Args,
|
||||
typename std::enable_if<std::is_function<Signature>::value,Signature>::type* = nullptr>
|
||||
R call_generic( const std::function<R(const std::function<Signature>&,Args...)>& f,
|
||||
variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||
{
|
||||
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
||||
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||
detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>(1) );
|
||||
return call_generic<R,Args...>( this->bind_first_arg<R,const std::function<Signature>&,Args...>( f, arg0 ), a0+1, e, max_depth - 1 );
|
||||
return call_generic<R,Args...>( this->bind_first_arg<R,const std::function<Signature>&,Args...>( f,
|
||||
arg0 ), a0+1, e, max_depth - 1 );
|
||||
}
|
||||
|
||||
template<typename R, typename Arg0, typename ... Args>
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ template<int L,typename Visitor,typename Data,typename T, typename ... Types>
|
|||
static const fc::array<typename Visitor::result_type(*)(Visitor&,Data),L>
|
||||
init_wrappers( Visitor& v, Data d, typename Visitor::result_type(**funcs)(Visitor&,Data) = 0 )
|
||||
{
|
||||
fc::array<typename Visitor::result_type(*)(Visitor&,Data),L> result;
|
||||
fc::array<typename Visitor::result_type(*)(Visitor&,Data),L> result{};
|
||||
if( !funcs ) funcs = result.begin();
|
||||
*funcs++ = [] ( Visitor& v, Data d ) { return v( *reinterpret_cast<T*>( d ) ); };
|
||||
init_wrappers<L,Visitor,Data,Types...>( v, d, funcs );
|
||||
|
|
@ -244,7 +244,7 @@ template<int L,typename Visitor,typename Data,typename T, typename ... Types>
|
|||
static const fc::array<typename Visitor::result_type(*)(Visitor&,Data),L>
|
||||
init_const_wrappers( Visitor& v, Data d, typename Visitor::result_type(**funcs)(Visitor&,Data) = 0 )
|
||||
{
|
||||
fc::array<typename Visitor::result_type(*)(Visitor&,Data),L> result;
|
||||
fc::array<typename Visitor::result_type(*)(Visitor&,Data),L> result{};
|
||||
if( !funcs ) funcs = result.begin();
|
||||
*funcs++ = [] ( Visitor& v, Data d ) { return v( *reinterpret_cast<const T*>( d ) ); };
|
||||
init_const_wrappers<L,Visitor,Data,Types...>( v, d, funcs );
|
||||
|
|
|
|||
Loading…
Reference in a new issue