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