diff --git a/include/flatmemory/details/containers/unordered_set.hpp b/include/flatmemory/details/containers/unordered_set.hpp index ec59089..25f8253 100644 --- a/include/flatmemory/details/containers/unordered_set.hpp +++ b/include/flatmemory/details/containers/unordered_set.hpp @@ -27,6 +27,9 @@ class UnorderedSet // Data to be accessed std::unordered_set, Hash, Equal, Allocator> m_data; + using iterator = std::unordered_set, Hash, Equal, Allocator>::iterator; + using const_iterator = std::unordered_set, Hash, Equal, Allocator>::const_iterator; + public: explicit UnorderedSet(NumBytes n = 1000000) : m_storage(ByteBufferSegmented(n)) { } @@ -41,10 +44,10 @@ class UnorderedSet * Iterators */ - [[nodiscard]] decltype(auto) begin() { return m_data.begin(); } - [[nodiscard]] decltype(auto) begin() const { return m_data.begin(); } - [[nodiscard]] decltype(auto) end() { return m_data.end(); } - [[nodiscard]] decltype(auto) end() const { return m_data.end(); } + [[nodiscard]] iterator begin() { return m_data.begin(); } + [[nodiscard]] const_iterator begin() const { return m_data.begin(); } + [[nodiscard]] iterator end() { return m_data.end(); } + [[nodiscard]] const_iterator end() const { return m_data.end(); } /** @@ -87,8 +90,8 @@ class UnorderedSet [[nodiscard]] size_t count(ConstView key) const { return m_data.count(key); } - [[nodiscard]] decltype(auto) find(ConstView key) { return m_data.find(key); } - [[nodiscard]] decltype(auto) find(ConstView key) const { return m_data.find(key); } + [[nodiscard]] iterator find(ConstView key) { return m_data.find(key); } + [[nodiscard]] const_iterator find(ConstView key) const { return m_data.find(key); } [[nodiscard]] bool contains(ConstView key) const { return m_data.contains(key); } }; diff --git a/include/flatmemory/details/containers/vector.hpp b/include/flatmemory/details/containers/vector.hpp index b95fd09..81469cf 100644 --- a/include/flatmemory/details/containers/vector.hpp +++ b/include/flatmemory/details/containers/vector.hpp @@ -30,6 +30,9 @@ class VariableSizedTypeVector // Data to be accessed std::vector> m_data; + using iterator = std::vector>::iterator; + using const_iterator = std::vector>::const_iterator; + public: explicit VariableSizedTypeVector(NumBytes n = 1000000) : m_storage(ByteBufferSegmented(n)) { } @@ -68,10 +71,10 @@ class VariableSizedTypeVector * Iterators */ - [[nodiscard]] decltype(auto) begin() { return m_data.begin(); } - [[nodiscard]] decltype(auto) begin() const { return m_data.begin(); } - [[nodiscard]] decltype(auto) end() { return m_data.end(); } - [[nodiscard]] decltype(auto) end() const { return m_data.end(); } + [[nodiscard]] iterator begin() { return m_data.begin(); } + [[nodiscard]] const_iterator begin() const { return m_data.begin(); } + [[nodiscard]] iterator end() { return m_data.end(); } + [[nodiscard]] const_iterator end() const { return m_data.end(); } /** @@ -112,6 +115,9 @@ class FixedSizedTypeVector const Builder m_default_builder; + using iterator = std::vector>::iterator; + using const_iterator = std::vector>::const_iterator; + public: FixedSizedTypeVector(Builder&& default_builder, NumBytes n = 1000000) : m_storage(ByteBufferSegmented(n)) @@ -157,10 +163,10 @@ class FixedSizedTypeVector * Iterators */ - [[nodiscard]] decltype(auto) begin() { return m_data.begin(); } - [[nodiscard]] decltype(auto) begin() const { return m_data.begin(); } - [[nodiscard]] decltype(auto) end() { return m_data.end(); } - [[nodiscard]] decltype(auto) end() const { return m_data.end(); } + [[nodiscard]] iterator begin() { return m_data.begin(); } + [[nodiscard]] const_iterator begin() const { return m_data.begin(); } + [[nodiscard]] iterator end() { return m_data.end(); } + [[nodiscard]] const_iterator end() const { return m_data.end(); } /** diff --git a/include/flatmemory/details/types/vector.hpp b/include/flatmemory/details/types/vector.hpp index a06e36d..7c06688 100644 --- a/include/flatmemory/details/types/vector.hpp +++ b/include/flatmemory/details/types/vector.hpp @@ -94,6 +94,9 @@ namespace flatmemory std::vector m_data; ByteBuffer m_buffer; + using iterator = std::vector::iterator; + using const_iterator = std::vector::const_iterator; + /* Implement IBuilder interface. */ template friend class IBuilder; @@ -164,10 +167,10 @@ namespace flatmemory * Iterators */ - decltype(auto) begin() { return m_data.begin(); } - decltype(auto) begin() const { return m_data.begin(); } - decltype(auto) end() { return m_data.end(); } - decltype(auto) end() const { return m_data.end(); } + iterator begin() { return m_data.begin(); } + const_iterator begin() const { return m_data.begin(); } + iterator end() { return m_data.end(); } + const_iterator end() const { return m_data.end(); } /** * Capacity