template<typename T>
class Class {
public:
Class() {}
};
class Typename { };
template<typename T>
class Nested { };
template<bool flag>
class BoolTemplate {
public:
BoolTemplate() {}
};
template<int param>
class IntTemplate {
public:
IntTemplate() {}
};
template<unsigned param>
class UnsignedIntTemplate {
public:
UnsignedIntTemplate() {}
};
template<long long param>
class LongLongTemplate {
public:
LongLongTemplate() {}
};
template<unsigned long long param>
class UnsignedLongLongTemplate {
public:
UnsignedLongLongTemplate() {}
};
template<>
class BoolTemplate<true> {
public:
BoolTemplate() {}
template<class T> void Foo(T arg) {}
};
void template_mangling() {
Class<Typename> c1;
Class<const Typename> c1_const;
Class<volatile Typename> c1_volatile;
Class<const volatile Typename> c1_cv;
Class<Nested<Typename> > c2;
Class<int * const> c_intpc;
Class<int()> c_ft;
Class<int[]> c_inti;
Class<int[5]> c_int5;
Class<const int[5]> c_intc5;
Class<int * const[5]> c_intpc5;
BoolTemplate<false> _false;
BoolTemplate<true> _true;
_true.Foo(1);
IntTemplate<0> zero;
IntTemplate<5> five;
IntTemplate<11> eleven;
IntTemplate<256> _256;
IntTemplate<513> _513;
IntTemplate<1026> _1026;
IntTemplate<65535> ffff;
IntTemplate<-1> neg_1;
IntTemplate<-9> neg_9;
IntTemplate<-10> neg_10;
IntTemplate<-11> neg_11;
UnsignedIntTemplate<4294967295> ffffffff;
LongLongTemplate<-9223372036854775807LL-1LL> int64_min;
LongLongTemplate<9223372036854775807LL> int64_max;
UnsignedLongLongTemplate<18446744073709551615ULL> uint64_max;
UnsignedLongLongTemplate<(unsigned long long)-1> uint64_neg_1;
}
namespace space {
template<class T> const T& foo(const T& l) { return l; }
}
void use() {
space::foo(42);
}
typedef void (*FunctionPointer)(void);
template <FunctionPointer function>
void FunctionPointerTemplate() {
function();
}
void spam() {
FunctionPointerTemplate<spam>();
}
template <typename ...Ts> void variadic_fn_template(const Ts &...args);
template <typename... Ts, typename... Us>
void multi_variadic_fn(Ts... ts, Us... us);
template <typename... Ts, typename C, typename... Us>
void multi_variadic_mixed(Ts... ts, C c, Us... us);
void variadic_fn_instantiate() {
variadic_fn_template(0, 1, 3, 4);
variadic_fn_template(0, 1, 'a', "b");
multi_variadic_fn<int, int>(1, 2, 3, 4, 5);
multi_variadic_fn<int, int, int>(1, 2, 3, 4, 5);
multi_variadic_mixed<int, int>(1, 2, 3);
multi_variadic_mixed<int, int>(1, 2, 3, 4);
}
template <typename ...Ts>
struct VariadicClass {
VariadicClass() { }
int x;
};
void variadic_class_instantiate() {
VariadicClass<int, char, bool> a;
VariadicClass<bool, char, int> b;
}
template <typename T>
struct Second {};
template <typename T, template <class> class>
struct Type {};
template <template <class> class T>
struct Type2 {};
template <template <class> class T, bool B>
struct Thing;
template <template <class> class T>
struct Thing<T, false> { };
template <template <class> class T>
struct Thing<T, true> { };
void template_template_fun(Type<Thing<Second, true>, Second>) { }
template <typename T>
void template_template_specialization();
template <>
void template_template_specialization<void (Type<Thing<Second, true>, Second>)>() {
}
template <decltype(nullptr)> struct S1 {};
void f(S1<nullptr>) {}
struct record {
int first;
int second;
};
template <const record &>
struct type1 {
};
extern const record inst;
void recref(type1<inst>) {}
struct _GUID {};
struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
template <typename T, const _GUID *G = &__uuidof(T)>
struct UUIDType1 {};
template <typename T, const _GUID &G = __uuidof(T)>
struct UUIDType2 {};
void fun(UUIDType1<uuid> a) {}
void fun(UUIDType2<uuid> b) {}
template <typename T> struct TypeWithFriendDefinition {
friend void FunctionDefinedWithInjectedName(TypeWithFriendDefinition<T>) {}
};
void CallFunctionDefinedWithInjectedName() {
FunctionDefinedWithInjectedName(TypeWithFriendDefinition<int>());
}
template <const _GUID *G>
struct UUIDType3 {
void foo() {}
};
template <const _GUID *G>
struct UUIDType4 : UUIDType3<G> {
void bar() { UUIDType4::foo(); }
};
template struct UUIDType4<&__uuidof(uuid)>;
#ifdef _WIN64
template<__int128 N> struct Int128 {};
template<unsigned __int128 N> struct UInt128 {};
void fun_int128(Int128<0>) {}
void fun_int128(Int128<-1>) {}
void fun_int128(Int128<(__int128)9223372036854775807 * (__int128)9223372036854775807>) {}
void fun_uint128(UInt128<0>) {}
void fun_uint128(UInt128<(unsigned __int128)-1>) {}
void fun_uint128(UInt128<(unsigned __int128)9223372036854775807 * (unsigned __int128)9223372036854775807>) {}
#endif