
Slightly OT, but I was hoping someone here might know the magic incantation (which may involve a Boost library). Given a template class such as template <class T> struct S { void f(); void g() { T t(h()); cb(t) } T & h(); boost::function1<void, T &> cb; }; Is there a way to have S.f() behave differently depending on whether S.g() uses the default definition or whether it is specialized for this particular type? This detection needs to occur before S.g() is ever called. For example, the mere existance of the specialization template <> void S<int>::g() { ... } should trigger special logic in S<int>::f(). Thanks, Daniel P.S. The motivation for this is an attempt to retrofit a callback API that allows specialization of S.g() or the registration of a boost::function that gets called by the default S.g(). We need to disable callbacks until an actual function is registered via either method. It is easy to dispatch on registration of the boost::function; I don't know how to detect the specialization.