c++ - Function signature as a function template parameter -


i'd use function signature template argument. works great classes, when try same trick function templates, msvc throws error:

error c2768: 'func' : illegal use of explicit template arguments

here's code:

template <typename signature> void func();  template <typename r, typename a1> void func<r(a1)>(); 

what should make work?

you cannot partially specialize function template, not supported language. can create partially specialized class template static member function, , possibly trampoline function instantiate class template , invoke static function.

something this:

namespace detail {     template<typename signature>     struct helper;      template<typename r, typename a1>     struct helper<r(a1)>     {         static void call()         {             // stuff r , a1...         }     }; }  template<typename signature> void func() {     detail::helper<signature>::call(); } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -