From 11873bc3ed4b1f8cf0802a6c1fc2e9b85a5f9a9a Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 29 Jul 2021 22:55:27 -0500 Subject: [PATCH] [ox/std] Add implementation of initializer_list --- deps/ox/src/ox/std/initializerlist.hpp | 44 ++++++++++++++++++++++++++ deps/ox/src/ox/std/vector.hpp | 5 +-- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 deps/ox/src/ox/std/initializerlist.hpp diff --git a/deps/ox/src/ox/std/initializerlist.hpp b/deps/ox/src/ox/std/initializerlist.hpp new file mode 100644 index 00000000..a55f5f48 --- /dev/null +++ b/deps/ox/src/ox/std/initializerlist.hpp @@ -0,0 +1,44 @@ +/* + * Copyright 2015 - 2021 gary@drinkingtea.net + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#if __has_include() +#include +#else + +#include "types.hpp" + +namespace std { + +template +class initializer_list { + private: + T *m_begin = nullptr; + size_t m_size = 0; + + public: + constexpr initializer_list() noexcept = default; + + constexpr size_t size() const noexcept { + return m_size; + } + + constexpr T *begin() const noexcept { + return m_begin; + } + + constexpr T *end() const noexcept { + return m_begin + m_size; + } + + private: + constexpr initializer_list(T *begin, size_t size) noexcept: m_begin(begin), m_size(size) {} +}; + +} + +#endif \ No newline at end of file diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index 31415acd..4d7a04f6 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -8,11 +8,8 @@ #pragma once -#if __has_include() -#include -#endif - #include "bit.hpp" +#include "initializerlist.hpp" #include "iterator.hpp" #include "math.hpp" #include "new.hpp"