struct Nontemplate {
typedef int type;
};
template<typename T>
struct X {
__if_exists(Nontemplate::type) {
typedef Nontemplate::type type;
}
__if_exists(Nontemplate::value) {
typedef Nontemplate::value type2;
}
__if_not_exists(Nontemplate::value) {
typedef int type3;
}
__if_exists(T::X) { typedef T::X type4;
}
};
X<int>::type i1;
X<int>::type2 i2; X<int>::type3 i3;
X<int>::type4 i4;
struct HasFoo {
void foo();
};
struct HasBar {
void bar(int);
void bar(float);
};
template<typename T>
void f(T t) {
__if_exists(T::foo) {
{ }
t.foo();
}
__if_not_exists(T::bar) {
int *i = t; { }
}
int array2[] = {
0,
__if_exists(T::bar) {2, } 3
};
}
template void f(HasFoo); template void f(HasBar);
template<typename T, typename ...Ts>
void g(T, Ts...) {
__if_exists(T::operator Ts) { }
__if_not_exists(Ts::operator T) { }
}