From 180f79fae953d7305c569d700e81fdde70a97cd6 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 7 Jun 2021 21:54:46 +0200 Subject: [PATCH] Replace std::array with C array --- .../implem/reversed_sized_array_bt.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/duckhandy/implem/reversed_sized_array_bt.hpp b/include/duckhandy/implem/reversed_sized_array_bt.hpp index e31641d..9085b00 100644 --- a/include/duckhandy/implem/reversed_sized_array_bt.hpp +++ b/include/duckhandy/implem/reversed_sized_array_bt.hpp @@ -18,7 +18,6 @@ #ifndef idFC25566D624140559C54B39FFFE52F04 #define idFC25566D624140559C54B39FFFE52F04 -#include #include #include #if !defined(INT_CONV_WITHOUT_HELPERS) @@ -36,7 +35,7 @@ namespace dhandy { public: constexpr static const std::size_t capacity = S; - using iterator = typename std::array::iterator; + using iterator = T*; constexpr ReversedSizedArray() = default; ~ReversedSizedArray() = default; @@ -45,11 +44,11 @@ namespace dhandy { constexpr const T operator[] (std::size_t idx) const { if (idx >= size()) throw std::out_of_range("Out of bound array access"); return m_data[idx + m_curr + 1]; } constexpr T& operator[] (std::size_t idx) { if (idx >= size()) throw std::out_of_range("Out of bound array access"); return m_data[idx + m_curr + 1]; } constexpr void push_front (const T& itm) { if (size() == S) throw std::length_error("ReversedSizedArray is full"); m_data[m_curr--] = itm; } - constexpr const T* data() const { return m_data.data() + m_curr + 1; } - constexpr const T* base_ptr() const { return m_data.data(); } - constexpr iterator begin() { return m_data.begin() + m_curr + 1; } - constexpr iterator end() { return m_data.end(); } - constexpr const T& back() const { return *(m_data.data() + S - 1); } + constexpr const T* data() const { return m_data + m_curr + 1; } + constexpr const T* base_ptr() const { return m_data; } + constexpr iterator begin() { return m_data + m_curr + 1; } + constexpr iterator end() { return m_data + S; } + constexpr const T& back() const { return *(m_data + S - 1); } template constexpr V to() const { return V(data(), size() - (not empty() and not back() ? 1 : 0)); } @@ -68,13 +67,13 @@ namespace dhandy { #endif private: - std::array m_data {}; + T m_data[S]; std::size_t m_curr {S - 1}; }; namespace implem { template - constexpr auto elements_or_empty_to_tuple (const std::array& elems, std::size_t from_idx, std::index_sequence) { + constexpr auto elements_or_empty_to_tuple (const T (&elems)[S], std::size_t from_idx, std::index_sequence) { return std::make_tuple((from_idx + Indices < S ? elems[from_idx + Indices] : T{})...); } } //namespace implem