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
16namespace std
17{
18
19template<class E>
20class initializer_list
21{
22public:
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 const E* data() const noexcept; // constexpr in C++14
34 size_t size() const noexcept; // constexpr in C++14
35 bool empty() const noexcept; // constexpr in C++14
36 const E* begin() const noexcept; // constexpr in C++14
37 const E* end() const noexcept; // constexpr in C++14
38};
39
40} // std
41
42*/
43
44#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
45# include <__cxx03/__config>
46#else
47# include <__config>
48# include <__cstddef/size_t.h>
49# include <version>
50
51# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
52# pragma GCC system_header
53# endif
54
55# ifndef _LIBCPP_CXX03_LANG
56
57namespace std // purposefully not versioned
58{
59
60template <class _Ep>
61class _LIBCPP_NO_SPECIALIZATIONS initializer_list {
62 const _Ep* __begin_;
63 size_t __size_;
64
65 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list(const _Ep* __b, size_t __s) noexcept
66 : __begin_(__b), __size_(__s) {}
67
68public:
69 typedef _Ep value_type;
70 typedef const _Ep& reference;
71 typedef const _Ep& const_reference;
72 typedef size_t size_type;
73
74 typedef const _Ep* iterator;
75 typedef const _Ep* const_iterator;
76
77 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list() noexcept : __begin_(nullptr), __size_(0) {}
78
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* data() const noexcept {
80 return __begin_;
81 }
82
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t size() const noexcept { return __size_; }
84
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool empty() const noexcept {
86 return __size_ == 0;
87 }
88
89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin() const noexcept {
90 return __begin_;
91 }
92
93 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end() const noexcept {
94 return __begin_ + __size_;
95 }
96};
97
98} // namespace std
99
100# endif // _LIBCPP_CXX03_LANG
101
102#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
103
104#endif // _LIBCPP_INITIALIZER_LIST
105