#include <type_traits>
#include <iostream>
template <typename T>
class is_int_or_float : public std::integral_constant<bool, std::is_same<T, int>::value || std::is_same<T, float>::value> {
};
template<typename T, typename Enable = void> //(2)
struct Helper {
static void go(const T&) {
std::cout << "all"<< std::endl;
}
};
template<typename T>
struct Helper<T, typename std::enable_if<is_int_or_float<T>::value>::type> { // (3)
static void go(const T&) {
std::cout << "int or float" << std::endl;
}
};
template<typename T>
struct Helper<T, typename std::enable_if<std::is_pointer<T>::value>::type> { // (3)
static void go(const T&) {
std::cout << "pointer" << std::endl;
}
};
template<typename T>
void func(const T& arg) {
Helper<T>::go(arg); // (1)
}
int main() {
char c;
int i;
float f;
int* p;
func(c);
func(i);
func(f);
func(p);
}
CiAgICAjaW5jbHVkZSA8dHlwZV90cmFpdHM+CiAgICAjaW5jbHVkZSA8aW9zdHJlYW0+CiAgICAgCiAgICAgCiAgICB0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4KICAgIGNsYXNzIGlzX2ludF9vcl9mbG9hdCA6IHB1YmxpYyBzdGQ6OmludGVncmFsX2NvbnN0YW50PGJvb2wsIHN0ZDo6aXNfc2FtZTxULCBpbnQ+Ojp2YWx1ZSB8fCBzdGQ6OmlzX3NhbWU8VCwgZmxvYXQ+Ojp2YWx1ZT4gewogICAgfTsKICAgICAKICAgICAKICAgIHRlbXBsYXRlPHR5cGVuYW1lIFQsIHR5cGVuYW1lIEVuYWJsZSA9IHZvaWQ+IC8vKDIpCiAgICBzdHJ1Y3QgSGVscGVyIHsKICAgICAgICBzdGF0aWMgdm9pZCBnbyhjb25zdCBUJikgewogICAgICAgICAgICAgICAgICAgIHN0ZDo6Y291dCA8PCAiYWxsIjw8IHN0ZDo6ZW5kbDsKICAgICAgICAgICAgfQogICAgfTsKICAgICAKICAgIHRlbXBsYXRlPHR5cGVuYW1lIFQ+CiAgICBzdHJ1Y3QgSGVscGVyPFQsIHR5cGVuYW1lIHN0ZDo6ZW5hYmxlX2lmPGlzX2ludF9vcl9mbG9hdDxUP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