summaryrefslogtreecommitdiff
path: root/kernel/lib/libcxx/include/initializer_list
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/lib/libcxx/include/initializer_list')
-rw-r--r--kernel/lib/libcxx/include/initializer_list57
1 files changed, 57 insertions, 0 deletions
diff --git a/kernel/lib/libcxx/include/initializer_list b/kernel/lib/libcxx/include/initializer_list
new file mode 100644
index 0000000..31aff39
--- /dev/null
+++ b/kernel/lib/libcxx/include/initializer_list
@@ -0,0 +1,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