c++ - Specializing only a part of a template function's implementation -
i'm wondering if anyhow possible partially specialize templated method behaviour in case 1 of template parameter it's of type.
template<class t> void foo(t& parameter) { /* generic - types - stuff */ if(t int) // pseudo-code, typeinfo? boost? { /* specific int processing might not compile other types */ } /* again common stuff */ } any suggestion welcome. thanks
if want specialize part of function have factor out part of function specialized implementations:
template<class t> void bar(t &t) {} void bar(int &i) { /* specific int processing might not compile other types */ } template<class t> void foo(t &t) { /* generic - types - stuff */ bar(t); /* again common stuff */ }
Comments
Post a Comment