Skip to content

Commit

Permalink
made some decltype(auto) more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Feb 11, 2024
1 parent 8e1a2f1 commit e69c4b4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
15 changes: 9 additions & 6 deletions include/flatmemory/details/containers/unordered_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class UnorderedSet
// Data to be accessed
std::unordered_set<ConstView<T>, Hash, Equal, Allocator> m_data;

using iterator = std::unordered_set<ConstView<T>, Hash, Equal, Allocator>::iterator;
using const_iterator = std::unordered_set<ConstView<T>, Hash, Equal, Allocator>::const_iterator;

public:
explicit UnorderedSet(NumBytes n = 1000000)
: m_storage(ByteBufferSegmented(n)) { }
Expand All @@ -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(); }


/**
Expand Down Expand Up @@ -87,8 +90,8 @@ class UnorderedSet

[[nodiscard]] size_t count(ConstView<T> key) const { return m_data.count(key); }

[[nodiscard]] decltype(auto) find(ConstView<T> key) { return m_data.find(key); }
[[nodiscard]] decltype(auto) find(ConstView<T> key) const { return m_data.find(key); }
[[nodiscard]] iterator find(ConstView<T> key) { return m_data.find(key); }
[[nodiscard]] const_iterator find(ConstView<T> key) const { return m_data.find(key); }

[[nodiscard]] bool contains(ConstView<T> key) const { return m_data.contains(key); }
};
Expand Down
22 changes: 14 additions & 8 deletions include/flatmemory/details/containers/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class VariableSizedTypeVector
// Data to be accessed
std::vector<View<T>> m_data;

using iterator = std::vector<View<T>>::iterator;
using const_iterator = std::vector<View<T>>::const_iterator;

public:
explicit VariableSizedTypeVector(NumBytes n = 1000000)
: m_storage(ByteBufferSegmented(n)) { }
Expand Down Expand Up @@ -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(); }


/**
Expand Down Expand Up @@ -112,6 +115,9 @@ class FixedSizedTypeVector

const Builder<T> m_default_builder;

using iterator = std::vector<View<T>>::iterator;
using const_iterator = std::vector<View<T>>::const_iterator;

public:
FixedSizedTypeVector(Builder<T>&& default_builder, NumBytes n = 1000000)
: m_storage(ByteBufferSegmented(n))
Expand Down Expand Up @@ -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(); }


/**
Expand Down
11 changes: 7 additions & 4 deletions include/flatmemory/details/types/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ namespace flatmemory
std::vector<T_> m_data;
ByteBuffer m_buffer;

using iterator = std::vector<T_>::iterator;
using const_iterator = std::vector<T_>::const_iterator;

/* Implement IBuilder interface. */
template<typename>
friend class IBuilder;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e69c4b4

Please sign in to comment.