blob: 31aff3932acf1ffc3485d7ec42dcf67275d81218 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the BastionOS freestanding C++ standard library.
//
// The compiler generates calls to std::initializer_list's private constructor.
// The memory layout MUST match what Clang expects.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBBASTION_INITIALIZER_LIST
#define _LIBBASTION_INITIALIZER_LIST
#include <__config>
#include <cstddef>
_LIBBASTION_BEGIN_NAMESPACE_STD
template<class _Ep>
class initializer_list {
public:
using value_type = _Ep;
using reference = const _Ep&;
using const_reference = const _Ep&;
using size_type = size_t;
using iterator = const _Ep*;
using const_iterator = const _Ep*;
_LIBBASTION_NODISCARD constexpr size_type size() const noexcept { return __size_; }
_LIBBASTION_NODISCARD constexpr const_iterator begin() const noexcept { return __begin_; }
_LIBBASTION_NODISCARD constexpr const_iterator end() const noexcept { return __begin_ + __size_; }
constexpr initializer_list() noexcept : __begin_(nullptr), __size_(0) {}
private:
// Clang constructs initializer_list with (pointer, size).
// This constructor and the field order MUST match the compiler's ABI.
constexpr initializer_list(const _Ep* __b, size_t __s) noexcept
: __begin_(__b), __size_(__s) {}
const _Ep* __begin_;
size_t __size_;
};
template<class _Ep>
_LIBBASTION_NODISCARD inline constexpr const _Ep* begin(initializer_list<_Ep> __il) noexcept {
return __il.begin();
}
template<class _Ep>
_LIBBASTION_NODISCARD inline constexpr const _Ep* end(initializer_list<_Ep> __il) noexcept {
return __il.end();
}
_LIBBASTION_END_NAMESPACE_STD
#endif // _LIBBASTION_INITIALIZER_LIST
|