[ox/std] Add implementation of initializer_list

This commit is contained in:
Gary Talent 2021-07-29 22:55:27 -05:00
parent f53b8e38dc
commit 11873bc3ed
2 changed files with 45 additions and 4 deletions

44
deps/ox/src/ox/std/initializerlist.hpp vendored Normal file
View File

@ -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(<initializer_list>)
#include <initializer_list>
#else
#include "types.hpp"
namespace std {
template<typename T>
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

View File

@ -8,11 +8,8 @@
#pragma once
#if __has_include(<initializer_list>)
#include <initializer_list>
#endif
#include "bit.hpp"
#include "initializerlist.hpp"
#include "iterator.hpp"
#include "math.hpp"
#include "new.hpp"