[compiler-rt] Add weak defs for .*contiguous_container.* functions (#120376)
[llvm-project.git] / clang / test / CXX / temp / temp.decls / temp.variadic / sizeofpack.cpp
blob50dedb1a158d3624db58ad5791e9f146d649a702
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
3 // expected-no-diagnostics
5 namespace pr12262 {
7 template<typename T, typename... Ts>
8 void abc1(int (*xxx)[sizeof ... (Ts) + 1]);
10 void qq1 () {
11 abc1<int>(0);
12 abc1<int,double>(0);
16 template <unsigned N> class array {};
19 template<typename T, typename... Types>
20 array<sizeof...(Types)> make_array1(Types&&... args);
22 void qq2 () {
23 array<1> arr = make_array1<int>(1);
24 array<3> arr2 = make_array1<int>(1,array<5>(),0.1);
28 template<typename T, typename... Types>
29 int make_array(array<sizeof...(Types)>&, Types... args);
31 void qq3 () {
32 array<1> a1;
33 int aa1 = make_array<int>(a1,1);
34 array<2> a2;
35 int aa2 = make_array<int>(a2, 0L, "abc");
39 template<typename ... Ts>
40 struct AAA {
41 template<typename T, typename... Types>
42 static array<sizeof...(Types)> make_array(Types ... args);
45 void qq4 () {
46 array<2> arr2 = AAA<int, int>::make_array<int>(1,2);
52 namespace pr12439 {
54 template<class... Members>
55 struct X {
56 template<int Idx>
57 using get_t = decltype(sizeof...(Members));
59 template<int i>
60 get_t<i> get();
63 template<class... Members>
64 template<int i>
65 typename X<Members...>::template get_t<i> X<Members...>::get()
67 return 0;
73 namespace pr13272 {
75 template<bool B, class T = void>
76 struct enable_if { };
78 template<class T> struct enable_if<true, T> {
79 typedef T type;
82 class Exception {};
84 template<class Ex, typename... Args>
85 void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) {
86 return;
89 void test() {
90 cxx_throw<Exception>("Youpi",1);
96 namespace pr13817 {
98 template <unsigned>
99 struct zod;
101 template <>
102 struct zod<1> {};
104 template <typename T, typename ... Ts>
105 zod<sizeof...(Ts)> make_zod(Ts ...) {
106 return zod<sizeof...(Ts)>();
109 int main(int argc, char *argv[])
111 make_zod<int>(1);
112 return 0;
118 namespace pr14273 {
120 template<typename T, int i>
121 struct myType
122 { };
124 template<typename T, typename... Args>
125 struct Counter
127 static const int count = 1 + Counter<Args...>::count;
130 template<typename T>
131 struct Counter<T>
133 static const int count = 1;
136 template<typename Arg, typename... Args>
137 myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args)
139 return 0;
142 void func(void)
144 make_array_with_type<char>(1,2,3);
150 namespace pr15112
152 template<bool, typename _Tp = void>
153 struct enable_if
154 { };
155 template<typename _Tp>
156 struct enable_if<true,_Tp>
157 { typedef _Tp type; };
159 typedef __typeof__(sizeof(int)) size_t;
161 template <size_t n, typename T, typename... Args>
162 struct is_array_of { static const bool value = true; };
164 struct cpu { using value_type = void; };
166 template <size_t Order, typename T>
167 struct coords_alias { typedef T type; };
169 template <size_t Order, typename MemoryTag>
170 using coords = typename coords_alias<Order, MemoryTag>::type;
172 template <typename MemTag, typename... Args>
173 typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value,
174 coords<sizeof...(Args), MemTag>>::type
175 mkcoords(Args... args);
177 auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul);
181 namespace pr12699 {
183 template<bool B>
184 struct bool_constant
186 static const bool value = B;
189 template<typename... A>
190 struct F
192 template<typename... B>
193 using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>;
195 template<typename... B, typename = SameSize<B...>>
196 F(B...) { }
199 void func()
201 F<int> f1(3);
206 #if __cplusplus >= 202002L
207 namespace GH81436 {
209 template <class E> struct Bar;
211 template <class E>
212 Bar(E) -> Bar<E>;
214 template <int> struct Foo {};
216 // Bar<Ts> doesn't have to be of a complete type.
217 template <class... Ts>
218 auto func() requires requires(Bar<Ts> ...init_lists) {
219 sizeof...(init_lists) > 0;
220 } {}
222 void f() { func<int>(); }
224 } // namespace GH81436
225 #endif