diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index 7b36c09..f8416a0 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -67,57 +67,31 @@ namespace chaiscript } - - template - struct Indexes - { - }; - - template - struct Make_Indexes - { - typedef typename Make_Indexes::indexes indexes; - }; - - template - struct Make_Indexes<0, I...> - { - typedef Indexes indexes; - }; - - - /** * Used by Proxy_Function_Impl to determine if it is equivalent to another * Proxy_Function_Impl object. This function is primarily used to prevent * registration of two functions with the exact same signatures */ - template - bool compare_types_cast(Indexes, Ret (*)(Params...), + template + bool compare_types_cast(Ret (*)(Params...), const std::vector ¶ms, const Type_Conversions_State &t_conversions) { try { + int i = 0; (void)params; (void)t_conversions; - (void)std::initializer_list{(boxed_cast(params[I], &t_conversions), 0)...}; + // this is ok because the order of evaluation of initializer lists is well defined + (void)std::initializer_list{(boxed_cast(params[i++], &t_conversions), 0)...}; return true; } catch (const exception::bad_boxed_cast &) { return false; } - - } - - template - bool compare_types_cast(Ret (*f)(Params...), - const std::vector ¶ms, const Type_Conversions_State &t_conversions) - { - typedef typename Make_Indexes::indexes indexes; - return compare_types_cast(indexes(), f, params, t_conversions); } template - Ret call_func(const chaiscript::dispatch::detail::Function_Signature &, Indexes, const Callable &f, - const std::vector ¶ms, const Type_Conversions_State &t_conversions) + Ret call_func(const chaiscript::dispatch::detail::Function_Signature &, + std::index_sequence, const Callable &f, + const std::vector ¶ms, const Type_Conversions_State &t_conversions) { (void)params; (void)t_conversions; return f(boxed_cast(params[I], &t_conversions)...); @@ -134,8 +108,7 @@ namespace chaiscript Ret call_func(const chaiscript::dispatch::detail::Function_Signature &sig, const Callable &f, const std::vector ¶ms, const Type_Conversions_State &t_conversions) { - typedef typename Make_Indexes::indexes indexes; - return call_func(sig, indexes(), f, params, t_conversions); + return call_func(sig, std::index_sequence_for{}, f, params, t_conversions); } }