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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -