Debian Codegraph @

llvm-project/libcxx/include/initializer_list

raw
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef _LIBCPP_INITIALIZER_LIST
11 #define _LIBCPP_INITIALIZER_LIST
12
13 /*
14 initializer_list synopsis
15
16 namespace std
17 {
18
19 template<class E>
20 class initializer_list
21 {
22 public:
23 typedef E value_type;
24 typedef const E& reference;
25 typedef const E& const_reference;
26 typedef size_t size_type;
27
28 typedef const E* iterator;
29 typedef const E* const_iterator;
30
31 initializer_list() noexcept; // constexpr in C++14
32
33 size_t size() const noexcept; // constexpr in C++14
34 const E* begin() const noexcept; // constexpr in C++14
35 const E* end() const noexcept; // constexpr in C++14
36 };
37
38 template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14
39 template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14
40
41 } // std
42
43 */
44
45 #include <__assert> // all public C++ headers provide the assertion handler
46 #include <__config>
47 #include <cstddef>
48
49 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50 # pragma GCC system_header
51 #endif
52
53 namespace std // purposefully not versioned
54 {
55
56 #ifndef _LIBCPP_CXX03_LANG
57
58 template<class _Ep>
59 class _LIBCPP_TEMPLATE_VIS initializer_list
60 {
61 const _Ep* __begin_;
62 size_t __size_;
63
64 _LIBCPP_INLINE_VISIBILITY
65 _LIBCPP_CONSTEXPR_SINCE_CXX14
66 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
67 : __begin_(__b),
68 __size_(__s)
69 {}
70 public:
71 typedef _Ep value_type;
72 typedef const _Ep& reference;
73 typedef const _Ep& const_reference;
74 typedef size_t size_type;
75
76 typedef const _Ep* iterator;
77 typedef const _Ep* const_iterator;
78
79 _LIBCPP_INLINE_VISIBILITY
80 _LIBCPP_CONSTEXPR_SINCE_CXX14
81 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
82
83 _LIBCPP_INLINE_VISIBILITY
84 _LIBCPP_CONSTEXPR_SINCE_CXX14
85 size_t size() const _NOEXCEPT {return __size_;}
86
87 _LIBCPP_INLINE_VISIBILITY
88 _LIBCPP_CONSTEXPR_SINCE_CXX14
89 const _Ep* begin() const _NOEXCEPT {return __begin_;}
90
91 _LIBCPP_INLINE_VISIBILITY
92 _LIBCPP_CONSTEXPR_SINCE_CXX14
93 const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
94 };
95
96 template<class _Ep>
97 inline _LIBCPP_INLINE_VISIBILITY
98 _LIBCPP_CONSTEXPR_SINCE_CXX14
99 const _Ep*
100 begin(initializer_list<_Ep> __il) _NOEXCEPT
101 {
102 return __il.begin();
103 }
104
105 template<class _Ep>
106 inline _LIBCPP_INLINE_VISIBILITY
107 _LIBCPP_CONSTEXPR_SINCE_CXX14
108 const _Ep*
109 end(initializer_list<_Ep> __il) _NOEXCEPT
110 {
111 return __il.end();
112 }
113
114 #endif // !defined(_LIBCPP_CXX03_LANG)
115
116 } // namespace std
117
118 #endif // _LIBCPP_INITIALIZER_LIST