From aa50364b57a4df7600b6294aba034c25782e3311 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 22 Mar 2019 09:17:01 -0500 Subject: [PATCH 1/3] help compiler infer correct templated method --- include/fc/rpc/api_connection.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/rpc/api_connection.hpp b/include/fc/rpc/api_connection.hpp index 1345c45..9045207 100644 --- a/include/fc/rpc/api_connection.hpp +++ b/include/fc/rpc/api_connection.hpp @@ -146,7 +146,7 @@ namespace fc { return f(); } - template + template::value,Signature>::type* = nullptr> R call_generic( const std::function,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth ) { FC_ASSERT( a0 != e, "too few arguments passed to method" ); @@ -154,7 +154,7 @@ namespace fc { detail::callback_functor arg0( get_connection(), a0->as(1) ); return call_generic( this->bind_first_arg,Args...>( f, std::function(arg0) ), a0+1, e, max_depth - 1 ); } - template + template::value,Signature>::type* = nullptr> R call_generic( const std::function&,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth ) { FC_ASSERT( a0 != e, "too few arguments passed to method" ); From 7b07f84f5100f22c1b2e58127c31c207c17223cc Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 22 Mar 2019 09:38:51 -0500 Subject: [PATCH 2/3] Fix spacing --- include/fc/rpc/api_connection.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/fc/rpc/api_connection.hpp b/include/fc/rpc/api_connection.hpp index 9045207..f606d32 100644 --- a/include/fc/rpc/api_connection.hpp +++ b/include/fc/rpc/api_connection.hpp @@ -146,21 +146,27 @@ namespace fc { return f(); } - template::value,Signature>::type* = nullptr> - R call_generic( const std::function,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth ) + template::value,Signature>::type* = nullptr> + R call_generic( const std::function,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 arg0( get_connection(), a0->as(1) ); - return call_generic( this->bind_first_arg,Args...>( f, std::function(arg0) ), a0+1, e, max_depth - 1 ); + return call_generic( this->bind_first_arg,Args...>( f, + std::function(arg0) ), a0+1, e, max_depth - 1 ); } - template::value,Signature>::type* = nullptr> - R call_generic( const std::function&,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth ) + template::value,Signature>::type* = nullptr> + R call_generic( const std::function&,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 arg0( get_connection(), a0->as(1) ); - return call_generic( this->bind_first_arg&,Args...>( f, arg0 ), a0+1, e, max_depth - 1 ); + return call_generic( this->bind_first_arg&,Args...>( f, + arg0 ), a0+1, e, max_depth - 1 ); } template From 843e000b745f90a3f69a3f46c4677997080fb9e5 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 25 Mar 2019 08:25:43 -0500 Subject: [PATCH 3/3] value initialize result --- include/fc/static_variant.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 0fa2a7b..4a440a2 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -226,7 +226,7 @@ template static const fc::array init_wrappers( Visitor& v, Data d, typename Visitor::result_type(**funcs)(Visitor&,Data) = 0 ) { - fc::array result; + fc::array result{}; if( !funcs ) funcs = result.begin(); *funcs++ = [] ( Visitor& v, Data d ) { return v( *reinterpret_cast( d ) ); }; init_wrappers( v, d, funcs ); @@ -244,7 +244,7 @@ template static const fc::array init_const_wrappers( Visitor& v, Data d, typename Visitor::result_type(**funcs)(Visitor&,Data) = 0 ) { - fc::array result; + fc::array result{}; if( !funcs ) funcs = result.begin(); *funcs++ = [] ( Visitor& v, Data d ) { return v( *reinterpret_cast( d ) ); }; init_const_wrappers( v, d, funcs );