• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 @import cxx_templates_common;
2 
3 template<typename T> T f();
f(T t)4 template<typename T> T f(T t) { return t; }
5 namespace N {
6   template<typename T> T f();
f(T t)7   template<typename T> T f(T t) { return t; }
8 }
9 
10 template<typename> int template_param_kinds_1();
11 template<template<typename, int, int...> class> int template_param_kinds_2();
12 template<template<typename T, typename U, U> class> int template_param_kinds_3();
13 
14 template<typename T> struct SomeTemplate<T&> {};
15 template<typename T> struct SomeTemplate<T&>;
16 typedef SomeTemplate<int&> SomeTemplateIntRef;
17 
18 extern DefinedInCommon &defined_in_common;
19 
20 template<int> struct MergeTemplates;
21 MergeTemplates<0> *merge_templates_b;
22 
23 template<typename T> template<typename U>
24 constexpr int Outer<T>::Inner<U>::g() { return 2; }
25 static_assert(Outer<int>::Inner<int>::g() == 2, "");
26 
27 namespace TestInjectedClassName {
28   template<typename T> struct X { X(); };
29   typedef X<char[2]> B;
30 }
31 
32 @import cxx_templates_b_impl;
33 
34 template<typename T, typename> struct Identity { typedef T type; };
35 template<typename T> void UseDefinedInBImpl() {
36   typename Identity<DefinedInBImpl, T>::type dependent;
37   FoundByADL(dependent);
38   typename Identity<DefinedInBImpl, T>::type::Inner inner;
39   dependent.f();
40 }
41 
42 extern DefinedInBImpl &defined_in_b_impl;
43 
44 template<typename T>
45 struct RedeclareTemplateAsFriend {
46   template<typename U>
47   friend struct RedeclaredAsFriend;
48 };
49 
50 void use_some_template_b() {
51   SomeTemplate<char[1]> a;
52   SomeTemplate<char[2]> b, c;
53   b = c;
54 
55   WithImplicitSpecialMembers<int> wism1, wism2(wism1);
56 }
57 
58 auto enum_b_from_b = CommonTemplate<int>::b;
59 const auto enum_c_from_b = CommonTemplate<int>::c;
60 
61 template<int> struct UseInt;
62 template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
63 constexpr void (*UseRedeclaredEnumB)(UseInt<1>) = UseRedeclaredEnum<int>;
64 
65 typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate3;
66 
67 template<typename> struct MergeSpecializations;
68 template<typename T> struct MergeSpecializations<T&> {
69   typedef int partially_specialized_in_b;
70 };
71 template<> struct MergeSpecializations<double> {
72   typedef int explicitly_specialized_in_b;
73 };
74 
75 template<typename U> using AliasTemplate = U;
76 
77 void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>);
78 inline int InstantiateWithAnonymousDeclsB(WithAnonymousDecls<int> x) {
79   return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e;
80 }
81 inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x) {
82   return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e;
83 }
84 
85 @import cxx_templates_a;
86 template<typename T> void UseDefinedInBImplIndirectly(T &v) {
87   PerformDelayedLookup(v);
88 }
89 
90 void TriggerInstantiation() {
91   UseDefinedInBImpl<void>();
92   Std::f<int>();
93   PartiallyInstantiatePartialSpec<int*>::foo();
94   WithPartialSpecialization<void(int)>::type x;
95 }
96