blob: 0289c8ada82357d47a5da0a95ff449eebbf2d0de [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;
32}
Richard Smithd46d6de2013-10-13 23:50:45 +000033
34template<int> struct MergeTemplates;
35MergeTemplates<0> *merge_templates_a;
Richard Smith01a73372013-10-15 22:02:41 +000036
37auto enum_a_from_a = CommonTemplate<int>::a;
38const auto enum_c_from_a = CommonTemplate<int>::c;
39
40template<int> struct UseInt;
41template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
42constexpr void (*UseRedeclaredEnumA)(UseInt<1>) = UseRedeclaredEnum<int>;
Richard Smith0c1065f2013-10-15 23:19:58 +000043
44template<typename> struct MergeSpecializations;
45template<typename T> struct MergeSpecializations<T*> {
46 typedef int partially_specialized_in_a;
47};
48template<> struct MergeSpecializations<char> {
49 typedef int explicitly_specialized_in_a;
50};
Richard Smithc264d352014-03-23 02:30:01 +000051
52void InstantiateWithFriend(Std::WithFriend<int> wfi) {}
Richard Smithdf352052014-05-22 20:59:29 +000053
54template<typename T> struct WithPartialSpecialization<T*> {
55 typedef int type;
56 T &f() { static T t; return t; }
57};
58typedef WithPartialSpecializationUse::type WithPartialSpecializationInstantiate;
Richard Smith871cd4c2014-05-23 21:00:28 +000059
60template<> struct WithExplicitSpecialization<int> {
61 int n;
62 template<typename T> T &inner_template() {
63 return n;
64 }
65};
Richard Smithdc5523d2014-07-11 00:20:06 +000066
67template<typename T> template<typename U>
68constexpr int Outer<T>::Inner<U>::f() { return 1; }
69static_assert(Outer<int>::Inner<int>::f() == 1, "");
Richard Smith547864d2014-07-11 18:22:58 +000070
71template<typename T> struct MergeTemplateDefinitions {
72 static constexpr int f();
73 static constexpr int g();
74};
75template<typename T> constexpr int MergeTemplateDefinitions<T>::f() { return 1; }
Richard Smithf59b7352014-07-28 21:16:37 +000076
77template<typename T> using AliasTemplate = T;
Richard Smith049fcd82014-07-29 00:58:01 +000078
79template<typename T> struct PartiallyInstantiatePartialSpec {};
80template<typename T> struct PartiallyInstantiatePartialSpec<T*> {
81 static T *foo() { return reinterpret_cast<T*>(0); }
82 static T *bar() { return reinterpret_cast<T*>(0); }
83};
84typedef PartiallyInstantiatePartialSpec<int*> PartiallyInstantiatePartialSpecHelper;