Disable a function by throwing error at compile-time with template class using traits
问题 I have a class, let's call it Foo with several methods: template<typename T> class Foo { public: Foo() { /* ... */ } bool do_something() { /* ... */ } // This method should be callable only if: // std::is_floating_point<T>::value == true void bar() { // Do stuff that is impossible with integer } }; I would like to be able to construct both Foo<double> and Foo<int> But I don't want to allow calls to bar() when the type T is not a floating point type. I also want the error to be generated at