SFINAE to make base template always result in error
问题 So I'm designing a sort of my_numeric_cast function to limit the types of conversions available when using a framework I'm writing. It was pretty straight forward to do something like template<typename To, typename From> constexpr To my_numeric_cast(From); template<> constexpr float my_numeric_cast<float, int>(int i) { return i; } Which works, allowing only casting from ints to floats whenever the cast is used. And producing a linkage error whenever a cast not in the white list is attempted.