Menu
  • HOME
  • TAGS

Does C++11, 14 or 17 provide a way to get just the arguments out of a decltype()?

c++,templates,c++11,argument-deduction

You use partial specialization: template <typename func_ptr_type, func_ptr_type real_func_ptr, const char *dl_name> struct Wrapper; template <typename Ret, typename... Args, Ret (*real_func_ptr)(Args...), const char *dl_name> struct Wrapper<Ret(*)(Args...), real_func_ptr, dl_name> { static Ret func(Args... args) { /* ... */ } }; The wrinkle is that because you can't partially specialize functions you...

Why can't the compiler deduce my template value from the function argument?

c++,templates,non-type,argument-deduction

If you want a run-time argument, use: void foo(E m) {} Which has a value m of type E. (note: no template<E m> required) If you want a compile-time argument, use: template<E m> void foo() {} and call: foo<A>(); Or if you want foo to work for all enumeration types:...