Skip to content

Instantly share code, notes, and snippets.

@multun
Created February 13, 2020 14:25
Show Gist options
  • Save multun/15667bae21de1e76aa8e7d56cf0abf3d to your computer and use it in GitHub Desktop.
Save multun/15667bae21de1e76aa8e7d56cf0abf3d to your computer and use it in GitHub Desktop.
#include <type_traits>
#include <iostream>
template<class T, class Enable = void>
struct A {
static void test() {
std::cout << "int" << std::endl;
}
};
template<class T>
struct A<T, typename std::enable_if<std::is_floating_point<T>::value>::type> {
static void test() {
std::cout << "float" << std::endl;
}
};
int main()
{
A<int>::test();
A<double>::test();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment