I want to create a constructor for a class using any integral type, but I distinguish between signed and unsigned. I do not want this to be a template for the class itself. The following does not work. Visual Studio simply says that no arguments will match.
class Thing{ public: template<typename Integral> Thing( typename std::enable_if< std::is_integral<Integral>::value && !std::is_same<Integral,bool>::value && std::is_signed<Integral>::value ,Integral >::type num ){ //constructor using signed variable as input } template<typename Integral> Thing( typename std::enable_if< std::is_integral<Integral>::value && !std::is_same<Integral,bool>::value && !std::is_signed<Integral>::value//notice this is different ,Integral >::type num ){ //constructor using unsigned variable as input } };
c ++ templates sfinae enable-if
tomatopipps
source share