1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <initializer_list>
11 
12 // template<class E> const E* begin(initializer_list<E> il);
13 
14 #include <initializer_list>
15 #include <cassert>
16 
17 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
18 
19 struct A
20 {
AA21     A(std::initializer_list<int> il)
22     {
23         const int* b = begin(il);
24         const int* e = end(il);
25         assert(il.size() == 3);
26         assert(e - b == il.size());
27         assert(*b++ == 3);
28         assert(*b++ == 2);
29         assert(*b++ == 1);
30     }
31 };
32 
33 #if _LIBCPP_STD_VER > 11
34 struct B
35 {
BB36     constexpr B(std::initializer_list<int> il)
37     {
38         const int* b = begin(il);
39         const int* e = end(il);
40         assert(il.size() == 3);
41         assert(e - b == il.size());
42         assert(*b++ == 3);
43         assert(*b++ == 2);
44         assert(*b++ == 1);
45     }
46 };
47 
48 #endif  // _LIBCPP_STD_VER > 11
49 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
50 
main()51 int main()
52 {
53 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
54     A test1 = {3, 2, 1};
55 #endif
56 #if _LIBCPP_STD_VER > 11
57     constexpr B test2 = {3, 2, 1};
58 #endif  // _LIBCPP_STD_VER > 11
59 }
60