I recently had a need to use template meta-programming to enable a particular set of constructors on a templated type only if one of the template parameters matched a particular value. Template specialization would have required copying a very large amount of code around, or using some undesirable inheritance tricks to get things to work. The normal means of using std::enable_if<> for functions and methods would not work because C++ constructors do not have return values. I found a work-around, but it has a few caveats that are worth pointing out for anyone else in a similar situation.
READ MORE »