1 // RUN: %clang_cc1 -std=c++20 -verify %s
2 // RUN: %clang_cc1 -std=c++17 -verify %s
5 char (&b(int(&&)[1]))[1]; // #1 expected-note{{too many initializers}}
6 char (&b(int(&&)[2]))[2]; // #2 expected-note{{too many initializers}}
9 static_assert(sizeof(b({1})) == 1); // #1
10 static_assert(sizeof(b({1, 2})) == 2); // #2
12 b({1, 2, 3}); // expected-error{{no matching function}}
21 char (&b(Bob(&&)[1]))[1]; // #1
22 char (&b(Bob(&&)[2]))[2]; // #2
25 static_assert(sizeof(b({})) == 1); // #1
26 static_assert(sizeof(b({Bob()})) == 1); // #1
27 static_assert(sizeof(b({2, Bob()})) == 2); // #2
36 char (&b(Kevin(&&)[2]))[2]; // #2 expected-note{{too few initializers}}
39 b({2}); // #1 expected-error{{no matching function}}
44 char (&b(int(&&)[1], float))[1]; // #1 expected-note{{candidate}}
45 char (&b(int(&&)[1], double))[2]; // #2 expected-note{{candidate}}
47 char (&c(float, int(&&)[1]))[1]; // #1 expected-note{{candidate}}
48 char (&c(double, int(&&)[1]))[2]; // #2 expected-note{{candidate}}
51 b({1}, 0); // expected-error{{is ambiguous}}
52 c(0, {1}); // expected-error{{is ambiguous}}
56 typedef decltype(sizeof(char)) size_t;
58 // sufficient initializer list
60 class initializer_list
{
64 constexpr initializer_list(const _E
*__b
, size_t __s
)
69 typedef _E value_type
;
70 typedef const _E
&reference
;
71 typedef const _E
&const_reference
;
72 typedef size_t size_type
;
74 typedef const _E
*iterator
;
75 typedef const _E
*const_iterator
;
77 constexpr initializer_list() : __begin_(nullptr), __size_(0) {}
79 constexpr size_t size() const { return __size_
; }
80 constexpr const _E
*begin() const { return __begin_
; }
81 constexpr const _E
*end() const { return __begin_
+ __size_
; }
90 char (&f(std::initializer_list
<char *>))[1]; // #1
91 char (&f(std::initializer_list
<ugly
>))[2]; // #2
93 // Pick #2 as #1 not viable (3->char * fails).
94 static_assert(sizeof(f({"hello", 3})) == 2); // expected-warning{{not allow}}