C ++ partial specialization (function pointers)
Can anyone please tell if below is legal c ++ or not?
template < typename s , s & (*fn) ( s * ) >
class c {};
// partial specialization
template < typename s , s & (*fn) ( s * ) >
class c < s*, s* & (*fn)(s**) {};
Errorg ++ (4.2.4): function call cannot appear in constant expression Error: template argument 2 is not valid
Although it works for explicit specialization
int & func ( int * ) { return 0; }
template <> class c < int , func> class c {};
+1
Shaikh amjad
a source
to share