1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
3 // This is heavily affected by the speculative resolution applied to CWG2311
4 // So behaviour shown here is subject to change.
6 // expected-no-diagnostics
9 typedef decltype(sizeof(int)) size_t;
11 // libc++'s implementation
13 class initializer_list
18 initializer_list(const _E
* __b
, size_t __s
)
24 typedef _E value_type
;
25 typedef const _E
& reference
;
26 typedef const _E
& const_reference
;
27 typedef size_t size_type
;
29 typedef const _E
* iterator
;
30 typedef const _E
* const_iterator
;
32 constexpr initializer_list() : __begin_(nullptr), __size_(0) {}
34 constexpr size_t size() const {return __size_
;}
35 const _E
* begin() const {return __begin_
;}
36 const _E
* end() const {return __begin_
+ __size_
;}
42 constexpr vector() : sz(0) {}
43 constexpr vector(initializer_list
<T
> ilist
) : sz(ilist
.size()) {}
44 constexpr vector(const vector
& other
) : sz(other
.sz
) {}
45 constexpr std::size_t size() const { return sz
; }
49 // https://github.com/llvm/llvm-project/pull/77768#issuecomment-1908062472
57 constexpr explicit B(A
) : called_ctor(0) {}
58 constexpr explicit B(std::vector
<A
>) : called_ctor(1) {}
63 constexpr C() : b({A()}) {}
66 static_assert(C().b
.called_ctor
== 0);
69 // https://github.com/llvm/llvm-project/pull/77768#issuecomment-1957171805
72 constexpr A(int x_
) {}
73 constexpr A(const std::vector
<A
>& a
) {}
77 constexpr std::vector
<A
> a
{1,2};
78 constexpr std::vector
<A
> b
{a
};
79 // -> constexpr std::vector<A> b(std::initializer_list<A>{ A(a) });
80 static_assert(b
.size() == 1);