
I have a question on usage of enable_if for faking partial specialization of function templates. Suppose I have a func F that has a general implementation, and a partial specialization for std::complex<T>. The obvious way to do this is to forward to a class member: template<typename T> struct F_impl { void DoF (); }; template<typename T> struct F_impl<std::complex<T> >{ void DoF (); }; template<typename T> void F () { F_impl<T>(); } Alternatively, I can define is_cmplx: template<typename T> struct is_cmplx { static const bool value = false; }; template<typename FLT> struct is_cmplx<std::complex<FLT> > { static const bool value = true; }; And use enable_if/disable_if. Both work. My question is, why would I prefer one over the other approach?