Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox-#2052 Implement move/copy constructor and assignment for FixedPositionContainer #2069

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
23c4bcc
iox-#2052 Implement copy/move ctors and assignments
Dennis40816 Oct 28, 2023
9addce9
iox-#2052 Extend `FixedPositionContainer` test
Dennis40816 Oct 28, 2023
27b0eac
iox-#2052 Refactor ctors and assignments
Dennis40816 Oct 28, 2023
642ddd5
iox-#2052 Refine test cases
Dennis40816 Oct 29, 2023
7c8b4c7
iox-#2052 Update unreleased document
Dennis40816 Oct 29, 2023
566c487
iox-#2052 Fix nitpick suggestion
Dennis40816 Oct 30, 2023
d97b10e
iox-#2052 Refine and rearrange existing test
Dennis40816 Oct 30, 2023
2f28470
iox-#2052 Fix expected result typo
Dennis40816 Oct 31, 2023
76e54bc
iox-#2052 Fix ctor and assignment
Dennis40816 Oct 31, 2023
7c0b2e4
iox-#2052 Add init() to reduce code duplication
Dennis40816 Oct 31, 2023
878f1fd
iox-#2052 Fix same values used in two consecutive tests
Dennis40816 Oct 31, 2023
5be9987
iox-#2052 Rename init() to copy_and_move_impl()
Dennis40816 Nov 1, 2023
6ea61c9
iox-#2052 Fix non-copyable class compile error
Dennis40816 Nov 4, 2023
0fd8af5
iox-#2052 Add missing tests
Dennis40816 Nov 4, 2023
461bf5c
iox-#2052 Fix member variable update logic
Dennis40816 Nov 4, 2023
fdaea90
iox-#2052 Remove unneccessary symbol
Dennis40816 Nov 4, 2023
19e0901
iox-#2052 Isolate helper for compiler compatibility
Dennis40816 Nov 7, 2023
46b1df5
iox-#2052 Move include to .inl file
Dennis40816 Nov 7, 2023
2f6787f
iox-#2052 Fix array out of bounds of m_next
Dennis40816 Nov 7, 2023
9eff9ce
iox-#2052 Simplify copy_and_move_impl
Dennis40816 Nov 8, 2023
24c5313
iox-#2052 Add `IteratorsAfterMoveWorkAsExpected`
Dennis40816 Nov 9, 2023
ae68307
Merge branch 'master' into iox-2052-fixedpositioncontainer-copymove-f…
Dennis40816 Nov 9, 2023
4c78838
iox-#2052 Add function `reset_member`
Dennis40816 Nov 10, 2023
5ee7097
iox-#2052 Remove reset_member
Dennis40816 Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,7 @@ namespace iox
template <typename T, uint64_t CAPACITY>
inline FixedPositionContainer<T, CAPACITY>::FixedPositionContainer() noexcept
{
for (IndexType i = 0; i < CAPACITY;)
{
m_status[i] = SlotStatus::FREE;

IndexType next = static_cast<IndexType>(i + 1U);
m_next[i] = next;
i = next;
}
m_next[Index::LAST] = Index::INVALID;

m_begin_free = Index::FIRST;
m_begin_used = Index::INVALID;
reset_member();
}

template <typename T, uint64_t CAPACITY>
Expand All @@ -58,12 +47,14 @@ inline FixedPositionContainer<T, CAPACITY>::~FixedPositionContainer() noexcept
template <typename T, uint64_t CAPACITY>
inline FixedPositionContainer<T, CAPACITY>::FixedPositionContainer(const FixedPositionContainer& rhs) noexcept
{
reset_member();
*this = rhs;
}

template <typename T, uint64_t CAPACITY>
inline FixedPositionContainer<T, CAPACITY>::FixedPositionContainer(FixedPositionContainer&& rhs) noexcept
{
reset_member();
*this = std::move(rhs);
}

Expand Down Expand Up @@ -175,6 +166,23 @@ inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rh
m_size = rhs.m_size;
}

template <typename T, uint64_t CAPACITY>
inline void FixedPositionContainer<T, CAPACITY>::reset_member() noexcept
{
for (IndexType i = 0; i < CAPACITY;)
{
m_status[i] = SlotStatus::FREE;

IndexType next = static_cast<IndexType>(i + 1U);
m_next[i] = next;
i = next;
}
m_next[Index::LAST] = Index::INVALID;

m_begin_free = Index::FIRST;
m_begin_used = Index::INVALID;
}

template <typename T, uint64_t CAPACITY>
inline void FixedPositionContainer<T, CAPACITY>::clear() noexcept
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ class FixedPositionContainer final
IndexType m_index;
};

private:
/// @brief Initialize member variables to prevent undefined or erroneous values.
void reset_member() noexcept;
elBoberido marked this conversation as resolved.
Show resolved Hide resolved

template <typename RhsType>
void copy_and_move_impl(RhsType&& rhs) noexcept;

Expand Down