[compiler-rt] Add weak defs for .*contiguous_container.* functions (#120376)
[llvm-project.git] / clang / test / CXX / temp / temp.decls / temp.variadic / fixed-expansion.cpp
bloba990c82564aa4036e03a741f58fd67bbe0c1cb93
1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
3 template<typename T, typename U> struct pair { };
4 template<typename ...Types> struct tuple { };
6 template<typename T, typename U>
7 struct is_same {
8 static const bool value = false;
9 };
11 template<typename T>
12 struct is_same<T, T> {
13 static const bool value = true;
16 namespace ExpandIntoFixed {
17 template<typename T,
18 typename U,
19 typename V = pair<T, U>,
20 typename W = V*>
21 class X0 { };
23 template<typename ...Ts>
24 class X1 {
25 public:
26 typedef X0<Ts...> type;
29 static_assert(is_same<X1<int, int>::type,
30 X0<int, int, pair<int, int>, pair<int, int>*>>::value,
31 "fails with two default arguments");
33 static_assert(is_same<X1<int, int, float>::type,
34 X0<int, int, float, float*>>::value,
35 "fails with one default argument");
37 static_assert(is_same<X1<int, int, float, double>::type,
38 X0<int, int, float, double>>::value,
39 "fails with no default arguments");
42 namespace ExpandIntoFixedShifted {
43 template<typename T,
44 typename U,
45 typename V = pair<T, U>,
46 typename W = V*>
47 class X0 { };
49 template<typename ...Ts>
50 class X1 {
51 public:
52 typedef X0<char, Ts...> type;
55 static_assert(is_same<X1<int>::type,
56 X0<char, int, pair<char, int>, pair<char, int>*>>::value,
57 "fails with two default arguments");
59 static_assert(is_same<X1<int, float>::type,
60 X0<char, int, float, float*>>::value,
61 "fails with one default argument");
63 static_assert(is_same<X1<int, float, double>::type,
64 X0<char, int, float, double>>::value,
65 "fails with no default arguments");
68 namespace Deduction {
69 template <typename X, typename Y = double> struct Foo {};
70 template <typename ...Args> tuple<Args...> &foo(Foo<Args...>);
72 void call_foo(Foo<int, float> foo_if, Foo<int> foo_i) {
73 tuple<int, float> &t1 = foo(foo_if);
74 tuple<int, double> &t2 = foo(foo_i);
78 namespace PR9021a {
79 template<typename, typename>
80 struct A { };
82 template<typename ...T>
83 struct B {
84 A<T...> a1;
87 void test() {
88 B<int, int> c;
92 namespace PR9021b {
93 template<class, class>
94 struct t2
99 template<template<class...> class M>
100 struct m
102 template<class... B>
103 using inner = M<B...>;
106 m<t2> sta2;
109 namespace PartialSpecialization {
110 template<typename T, typename U, typename V = U>
111 struct X0; // expected-note 2{{template is declared here}}
113 template<typename ...Ts>
114 struct X0<Ts...> { // expected-error {{class template partial specialization is not more specialized than the primary template}}
117 X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}}
118 X0<int, float> x0if;
119 X0<int, float, double> x0ifd;
122 namespace FixedAliasTemplate {
123 template<typename,typename,typename> struct S {};
124 template<typename T, typename U> using U = S<T, int, U>; // expected-note 2{{template parameter is declared here}}
125 template<typename...Ts> U<Ts...> &f(U<Ts...>, Ts...); // expected-error 2{{pack expansion used as argument for non-pack parameter of alias template}}
126 S<int, int, double> &s1 = f({}, 0, 0.0); // expected-error {{no matching function}}
129 namespace PR18401 {
130 template<typename... Args> struct foo { };
131 template<typename T, typename... Args> using bar = foo<T, Args...>; // expected-note 2{{template parameter is declared here}} expected-note {{'bar' declared here}}
132 template<typename T, typename... Args> using baz = bar<Args..., T>; // expected-error {{pack expansion used as argument for non-pack parameter of alias template}}
133 // FIXME: We should still record the alias template, but mark it as invalid.
134 template<typename...T> void f(baz<T...>); // expected-error {{no template named 'baz'; did you mean 'bar'}} expected-error {{pack expansion used as argument for non-pack}}
135 void g() { f(foo<int, char, double>()); } // expected-error {{no matching function}}