blob: 1ade811d71d5e7f30e601c057f718bb6d0ec33be [file] [log] [blame]
Richard Smith5de91b52013-06-25 01:25:15 +00001@import cxx_templates_common;
2
Richard Smith8f8f05c2013-06-24 04:45:28 +00003template<typename T> T f() { return T(); }
4template<typename T> T f(T);
5namespace N {
6 template<typename T> T f() { return T(); }
7 template<typename T> T f(T);
8}
Richard Smithbf78e642013-06-24 22:51:00 +00009
10template<int N> int template_param_kinds_1();
11template<template<typename T, int, int> class> int template_param_kinds_2();
12template<template<typename T, typename U, T> class> int template_param_kinds_3();
Richard Smith5de91b52013-06-25 01:25:15 +000013
14template<typename T> struct SomeTemplate<T*>;
15template<typename T> struct SomeTemplate<T*> {};
16typedef SomeTemplate<int*> SomeTemplateIntPtr;
Richard Smith0e5d7b82013-07-25 23:08:39 +000017
18template<typename T> void PerformDelayedLookup(T &t) {
19 t.f();
20 typename T::Inner inner;
21 FoundByADL(t);
22}
Richard Smithb71782b2013-08-01 04:12:04 +000023
24template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
Richard Smith7ecc31b2013-08-02 01:09:12 +000025
26template<typename T> struct RedeclaredAsFriend {};
Richard Smithd55889a2013-09-09 16:55:27 +000027
28void use_some_template_a() {
29 SomeTemplate<char[2]> a;
30 SomeTemplate<char[1]> b, c;
31 b = c;
Richard Smith8c913ec2014-08-14 02:21:01 +000032
33 (void)&WithImplicitSpecialMembers<int>::n;
Richard Smithd55889a2013-09-09 16:55:27 +000034}
Richard Smithd46d6de2013-10-13 23:50:45 +000035
36template<int> struct MergeTemplates;
37MergeTemplates<0> *merge_templates_a;
Richard Smith01a73372013-10-15 22:02:41 +000038
39auto enum_a_from_a = CommonTemplate<int>::a;
40const auto enum_c_from_a = CommonTemplate<int>::c;
41
42template<int> struct UseInt;
43template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
44constexpr void (*UseRedeclaredEnumA)(UseInt<1>) = UseRedeclaredEnum<int>;
Richard Smith0c1065f2013-10-15 23:19:58 +000045
46template<typename> struct MergeSpecializations;
47template<typename T> struct MergeSpecializations<T*> {
48 typedef int partially_specialized_in_a;
49};
50template<> struct MergeSpecializations<char> {
51 typedef int explicitly_specialized_in_a;
52};
Richard Smithc264d352014-03-23 02:30:01 +000053
54void InstantiateWithFriend(Std::WithFriend<int> wfi) {}
Richard Smithdf352052014-05-22 20:59:29 +000055
56template<typename T> struct WithPartialSpecialization<T*> {
57 typedef int type;
58 T &f() { static T t; return t; }
59};
60typedef WithPartialSpecializationUse::type WithPartialSpecializationInstantiate;
Richard Smith871cd4c2014-05-23 21:00:28 +000061
62template<> struct WithExplicitSpecialization<int> {
63 int n;
64 template<typename T> T &inner_template() {
65 return n;
66 }
67};
Richard Smithdc5523d2014-07-11 00:20:06 +000068
69template<typename T> template<typename U>
70constexpr int Outer<T>::Inner<U>::f() { return 1; }
71static_assert(Outer<int>::Inner<int>::f() == 1, "");
Richard Smith547864d2014-07-11 18:22:58 +000072
73template<typename T> struct MergeTemplateDefinitions {
74 static constexpr int f();
75 static constexpr int g();
76};
77template<typename T> constexpr int MergeTemplateDefinitions<T>::f() { return 1; }
Richard Smithf59b7352014-07-28 21:16:37 +000078
79template<typename T> using AliasTemplate = T;
Richard Smith049fcd82014-07-29 00:58:01 +000080
81template<typename T> struct PartiallyInstantiatePartialSpec {};
82template<typename T> struct PartiallyInstantiatePartialSpec<T*> {
83 static T *foo() { return reinterpret_cast<T*>(0); }
84 static T *bar() { return reinterpret_cast<T*>(0); }
85};
86typedef PartiallyInstantiatePartialSpec<int*> PartiallyInstantiatePartialSpecHelper;