Boost logo

Boost Users :

Subject: [Boost-users] Detect specialized template function?
From: dherring_at_[hidden]
Date: 2010-01-28 15:24:19


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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net