llvm-project
98 строк · 2.7 Кб
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/*
14initializer_list synopsis
15
16namespace std
17{
18
19template<class E>
20class initializer_list
21{
22public:
23typedef E value_type;
24typedef const E& reference;
25typedef const E& const_reference;
26typedef size_t size_type;
27
28typedef const E* iterator;
29typedef const E* const_iterator;
30
31initializer_list() noexcept; // constexpr in C++14
32
33size_t size() const noexcept; // constexpr in C++14
34const E* begin() const noexcept; // constexpr in C++14
35const E* end() const noexcept; // constexpr in C++14
36};
37
38template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14
39template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14
40
41} // std
42
43*/
44
45#include <__config>
46#include <cstddef>
47
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49# pragma GCC system_header
50#endif
51
52namespace std // purposefully not versioned
53{
54
55#ifndef _LIBCPP_CXX03_LANG
56
57template <class _Ep>
58class _LIBCPP_TEMPLATE_VIS initializer_list {
59const _Ep* __begin_;
60size_t __size_;
61
62_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
63: __begin_(__b),
64__size_(__s) {}
65
66public:
67typedef _Ep value_type;
68typedef const _Ep& reference;
69typedef const _Ep& const_reference;
70typedef size_t size_type;
71
72typedef const _Ep* iterator;
73typedef const _Ep* const_iterator;
74
75_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
76
77_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t size() const _NOEXCEPT { return __size_; }
78
79_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin() const _NOEXCEPT { return __begin_; }
80
81_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end() const _NOEXCEPT { return __begin_ + __size_; }
82};
83
84template <class _Ep>
85inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin(initializer_list<_Ep> __il) _NOEXCEPT {
86return __il.begin();
87}
88
89template <class _Ep>
90inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initializer_list<_Ep> __il) _NOEXCEPT {
91return __il.end();
92}
93
94#endif // !defined(_LIBCPP_CXX03_LANG)
95
96} // namespace std
97
98#endif // _LIBCPP_INITIALIZER_LIST
99