libhatchet
Loading...
Searching...
No Matches
hxinitializer_list.hpp
Go to the documentation of this file.
1#pragma once
2// SPDX-FileCopyrightText: © 2017-2026 Adrian Johnston.
3// SPDX-License-Identifier: MIT
4// This file is licensed under the MIT license found in the LICENSE.md file.
5
8
9#include "libhatchet.h"
10
11// HX_USE_MACROS_WITH_MODULE allows including macros alongside the module.
12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
14#endif
15
16#if HX_USE_LIBCXX
17#include <initializer_list>
18#elif defined _MSC_VER
19#error No custom <initializer_list> provided for MSVC. Set HX_USE_LIBCXX.
20#else // !HX_USE_LIBCXX
21
23namespace std {
24
25template<typename T>
26class initializer_list {
27public:
28 using value_type = T;
29 using reference = const T&;
30 using const_reference = const T&;
31 using size_type = size_t;
32 using iterator = const T*;
33 using const_iterator = const T*;
34
35 constexpr initializer_list(void) noexcept : m_begin(0), m_size(0u) { }
36 constexpr size_t size(void) const noexcept { return m_size; }
37 constexpr const T* begin(void) const noexcept { return m_begin; }
38 constexpr const T* end(void) const noexcept { return m_begin + m_size; }
39
40private:
41 constexpr initializer_list(const T* begin_, size_t size_) noexcept
42 : m_begin(begin_), m_size(size_) { }
43
44 const T* m_begin;
45 size_t m_size;
46};
47
48} // namespace std
50#endif // !HX_USE_LIBCXX
Provides core macros, memory management and feature detection.