blob: 8b97d22a370cd110115fc1099d80510144aaccc3 [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();
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}
Richard Smithbf78e642013-06-24 22:51:00 +00009
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();
Richard Smith5de91b52013-06-25 01:25:15 +000013
14template<typename T> struct SomeTemplate<T&> {};
15template<typename T> struct SomeTemplate<T&>;
16typedef SomeTemplate<int&> SomeTemplateIntRef;
Richard Smith0e5d7b82013-07-25 23:08:39 +000017
18extern DefinedInCommon &defined_in_common;
19
Richard Smithd46d6de2013-10-13 23:50:45 +000020template<int> struct MergeTemplates;
21MergeTemplates<0> *merge_templates_b;
22
Richard Smithdc5523d2014-07-11 00:20:06 +000023template<typename T> template<typename U>
24constexpr int Outer<T>::Inner<U>::g() { return 2; }
25static_assert(Outer<int>::Inner<int>::g() == 2, "");
26
Richard Smith0e5d7b82013-07-25 23:08:39 +000027@import cxx_templates_b_impl;
28
29template<typename T, typename> struct Identity { typedef T type; };
30template<typename T> void UseDefinedInBImpl() {
31 typename Identity<DefinedInBImpl, T>::type dependent;
32 FoundByADL(dependent);
33 typename Identity<DefinedInBImpl, T>::type::Inner inner;
34 dependent.f();
35}
36
37extern DefinedInBImpl &defined_in_b_impl;
38
Richard Smith7ecc31b2013-08-02 01:09:12 +000039template<typename T>
40struct RedeclareTemplateAsFriend {
41 template<typename U>
42 friend struct RedeclaredAsFriend;
43};
44
Richard Smithd55889a2013-09-09 16:55:27 +000045void use_some_template_b() {
46 SomeTemplate<char[1]> a;
47 SomeTemplate<char[2]> b, c;
48 b = c;
Richard Smith8c913ec2014-08-14 02:21:01 +000049
50 WithImplicitSpecialMembers<int> wism1, wism2(wism1);
Richard Smithd55889a2013-09-09 16:55:27 +000051}
52
Richard Smith01a73372013-10-15 22:02:41 +000053auto enum_b_from_b = CommonTemplate<int>::b;
54const auto enum_c_from_b = CommonTemplate<int>::c;
55
56template<int> struct UseInt;
57template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
58constexpr void (*UseRedeclaredEnumB)(UseInt<1>) = UseRedeclaredEnum<int>;
59
Richard Smith72544f82014-08-14 03:30:27 +000060typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate3;
61
Richard Smith0c1065f2013-10-15 23:19:58 +000062template<typename> struct MergeSpecializations;
63template<typename T> struct MergeSpecializations<T&> {
64 typedef int partially_specialized_in_b;
65};
66template<> struct MergeSpecializations<double> {
67 typedef int explicitly_specialized_in_b;
68};
69
Richard Smithf59b7352014-07-28 21:16:37 +000070template<typename U> using AliasTemplate = U;
71
Richard Smith0e5d7b82013-07-25 23:08:39 +000072@import cxx_templates_a;
73template<typename T> void UseDefinedInBImplIndirectly(T &v) {
74 PerformDelayedLookup(v);
75}
76
77void TriggerInstantiation() {
78 UseDefinedInBImpl<void>();
Richard Smith561e0dc2014-03-23 19:45:26 +000079 Std::f<int>();
Richard Smith049fcd82014-07-29 00:58:01 +000080 PartiallyInstantiatePartialSpec<int*>::foo();
Richard Smith72544f82014-08-14 03:30:27 +000081 WithPartialSpecialization<void(int)>::type x;
Richard Smith0e5d7b82013-07-25 23:08:39 +000082}