diff --git a/include/flatmemory/details/byte_buffer_segmented.hpp b/include/flatmemory/details/byte_buffer_segmented.hpp index d1d3394..8a5d6d1 100644 --- a/include/flatmemory/details/byte_buffer_segmented.hpp +++ b/include/flatmemory/details/byte_buffer_segmented.hpp @@ -18,7 +18,6 @@ #ifndef FLATMEMORY_BYTE_BUFFER_SEGMENTED_HPP_ #define FLATMEMORY_BYTE_BUFFER_SEGMENTED_HPP_ -#include "flatmemory/details/layout_utils.hpp" #include "flatmemory/details/type_traits.hpp" #include diff --git a/include/flatmemory/details/containers/unordered_set.hpp b/include/flatmemory/details/containers/unordered_set.hpp index 39faaea..8c33346 100644 --- a/include/flatmemory/details/containers/unordered_set.hpp +++ b/include/flatmemory/details/containers/unordered_set.hpp @@ -4,12 +4,10 @@ #include "flatmemory/details/builder.hpp" #include "flatmemory/details/byte_buffer_segmented.hpp" -#include "flatmemory/details/byte_buffer_utils.hpp" #include "flatmemory/details/type_traits.hpp" #include "flatmemory/details/view.hpp" #include "flatmemory/details/view_const.hpp" -#include #include namespace flatmemory @@ -42,8 +40,8 @@ class UnorderedSet // Data to be accessed std::unordered_set, Hash, Equal> m_data; - using iterator = std::unordered_set, Hash, Equal>::iterator; - using const_iterator = std::unordered_set, Hash, Equal>::const_iterator; + using iterator = typename std::unordered_set, Hash, Equal>::iterator; + using const_iterator = typename std::unordered_set, Hash, Equal>::const_iterator; public: explicit UnorderedSet(NumBytes n = 1000000) : m_storage(ByteBufferSegmented(n)) {} diff --git a/include/flatmemory/details/containers/vector.hpp b/include/flatmemory/details/containers/vector.hpp index d09fd1e..319e311 100644 --- a/include/flatmemory/details/containers/vector.hpp +++ b/include/flatmemory/details/containers/vector.hpp @@ -30,8 +30,8 @@ class VariableSizedTypeVector // Data to be accessed std::vector> m_data; - using iterator = std::vector>::iterator; - using const_iterator = std::vector>::const_iterator; + using iterator = typename std::vector>::iterator; + using const_iterator = typename std::vector>::const_iterator; public: explicit VariableSizedTypeVector(NumBytes n = 1000000) : m_storage(ByteBufferSegmented(n)) {} @@ -113,8 +113,8 @@ class FixedSizedTypeVector const Builder m_default_builder; - using iterator = std::vector>::iterator; - using const_iterator = std::vector>::const_iterator; + using iterator = typename std::vector>::iterator; + using const_iterator = typename std::vector>::const_iterator; public: FixedSizedTypeVector(Builder&& default_builder, NumBytes n = 1000000) : m_storage(ByteBufferSegmented(n)), m_default_builder(std::move(default_builder)) diff --git a/include/flatmemory/details/types/bitset.hpp b/include/flatmemory/details/types/bitset.hpp index 82842b3..e4dcbe9 100644 --- a/include/flatmemory/details/types/bitset.hpp +++ b/include/flatmemory/details/types/bitset.hpp @@ -33,10 +33,7 @@ #include #include #include -#include #include -#include -#include namespace flatmemory { @@ -257,7 +254,7 @@ class Operator> for (std::size_t index = 0; index < common_size; ++index) { - if (blocks[index] & other_blocks[index] != other_blocks[index]) + if (blocks[index] & (other_blocks[index] != other_blocks[index])) { // There exists a set bit in block that is not set in block. return false; @@ -308,7 +305,7 @@ class Operator> for (std::size_t index = 0; index < common_size; ++index) { - if (blocks[index] & other_blocks[index] > 0) + if (blocks[index] & (other_blocks[index] > 0)) { // block and other_block have set bits in common return false; @@ -535,7 +532,7 @@ class View> { private: using BitsetOperator = Operator>; - using const_iterator = BitsetOperator::const_iterator; + using const_iterator = typename BitsetOperator::const_iterator; uint8_t* m_buf; @@ -664,7 +661,7 @@ class ConstView> { private: using BitsetOperator = Operator>; - using const_iterator = BitsetOperator::const_iterator; + using const_iterator = typename BitsetOperator::const_iterator; const uint8_t* m_buf; @@ -754,7 +751,7 @@ class ConstView> * Getters */ - [[nodiscard]] uint8_t* buffer() { return m_buf; } + [[nodiscard]] const uint8_t* buffer() const { return m_buf; } [[nodiscard]] size_t buffer_size() const { @@ -785,7 +782,7 @@ class Builder> : public IBuilder>> { private: using BitsetOperator = Operator>; - using const_iterator = BitsetOperator::const_iterator; + using const_iterator = typename BitsetOperator::const_iterator; bool m_default_bit_value; Builder> m_blocks; diff --git a/include/flatmemory/details/types/trivial.hpp b/include/flatmemory/details/types/trivial.hpp index 1f08061..9263364 100644 --- a/include/flatmemory/details/types/trivial.hpp +++ b/include/flatmemory/details/types/trivial.hpp @@ -22,16 +22,11 @@ #include "flatmemory/details/byte_buffer.hpp" #include "flatmemory/details/byte_buffer_utils.hpp" #include "flatmemory/details/layout.hpp" -#include "flatmemory/details/layout_utils.hpp" #include "flatmemory/details/type_traits.hpp" #include "flatmemory/details/view.hpp" #include "flatmemory/details/view_const.hpp" -#include #include -#include -#include -#include namespace flatmemory { @@ -183,7 +178,7 @@ class ConstView> return sizeof(T); } - [[nodiscard]] uint8_t* buffer() { return m_buf; } + [[nodiscard]] const uint8_t* buffer() const { return m_buf; } }; } diff --git a/include/flatmemory/details/types/vector.hpp b/include/flatmemory/details/types/vector.hpp index a10b315..9face6b 100644 --- a/include/flatmemory/details/types/vector.hpp +++ b/include/flatmemory/details/types/vector.hpp @@ -33,7 +33,6 @@ #include #include #include -#include #include namespace flatmemory @@ -115,8 +114,8 @@ class Builder> : public IBuilder>> private: using T_ = typename maybe_builder::type; - using iterator = std::vector::iterator; - using const_iterator = std::vector::const_iterator; + using iterator = typename std::vector::iterator; + using const_iterator = typename std::vector::const_iterator; std::vector m_data; ByteBuffer m_buffer; @@ -365,7 +364,7 @@ class View> class iterator { private: - uint8_t* buf; + uint8_t* m_buf; public: using difference_type = std::ptrdiff_t; @@ -374,15 +373,15 @@ class View> using reference = typename maybe_view::type&; using iterator_category = std::forward_iterator_tag; - iterator(uint8_t* buf) : buf(buf) {} + iterator(uint8_t* buf) : m_buf(buf) {} [[nodiscard]] decltype(auto) operator*() const { constexpr bool is_trivial = IsTriviallyCopyable; if constexpr (is_trivial) { - assert(test_correct_alignment(buf)); - return read_value(buf); + assert(test_correct_alignment(m_buf)); + return read_value(m_buf); } else { @@ -395,11 +394,11 @@ class View> constexpr bool is_trivial = IsTriviallyCopyable; if constexpr (is_trivial) { - buf += sizeof(T); + m_buf += sizeof(T); } else { - buf += sizeof(offset_type); + m_buf += sizeof(offset_type); } return *this; } @@ -411,7 +410,7 @@ class View> return tmp; } - [[nodiscard]] bool operator==(const iterator& other) const { return buf == other.buf; } + [[nodiscard]] bool operator==(const iterator& other) const { return m_buf == other.m_buf; } [[nodiscard]] bool operator!=(const iterator& other) const { return !(*this == other); } }; @@ -463,7 +462,7 @@ class View> } else { - return View(m_buf + read_value(m_buf)); + return View(buf + read_value(buf)); } } @@ -657,7 +656,7 @@ class ConstView> } else { - return View(m_buf + read_value(m_buf)); + return View(buf + read_value(buf)); } } diff --git a/tests/unit/types/bitset.cpp b/tests/unit/types/bitset.cpp index e124852..32c92fe 100644 --- a/tests/unit/types/bitset.cpp +++ b/tests/unit/types/bitset.cpp @@ -17,7 +17,6 @@ #include #include -#include namespace flatmemory::tests {