1919#define IOX_HOOFS_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
2020
2121#include " iox/fixed_position_container.hpp"
22+ #include " iox/iceoryx_hoofs_deployment.hpp"
2223
2324namespace iox
2425{
@@ -86,80 +87,6 @@ FixedPositionContainer<T, CAPACITY>::operator=(FixedPositionContainer&& rhs) noe
8687 return *this ;
8788}
8889
89- #ifndef IOX_HOOFS_SUBSET
90- template <typename T, uint64_t CAPACITY>
91- template <MoveAndCopyOperations Opt, typename RhsType>
92- inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rhs) noexcept
93- {
94- // alias helper struct
95- using Helper = MoveAndCopyHelper<Opt>;
96-
97- constexpr bool is_ctor = Helper::is_ctor;
98- constexpr bool is_move = Helper::is_move;
99-
100- // status array is not yet initialized for constructor creation
101- if constexpr (is_ctor)
102- {
103- for (IndexType i = 0 ; i < CAPACITY; ++i)
104- {
105- m_status[i] = SlotStatus::FREE;
106- }
107- }
108-
109- IndexType i{Index::FIRST};
110- auto rhs_it = (std::forward<RhsType>(rhs)).begin ();
111-
112- for (; rhs_it.to_index () != Index::INVALID; ++i, ++rhs_it)
113- {
114- if (m_status[i] == SlotStatus::USED)
115- {
116- // When the slot is in the 'USED' state, it is safe to proceed with either construction (ctor) or assignment
117- // operation. Therefore, creation can be carried out according to the option specified by Opt.
118- Helper::transfer (m_data[i], Helper::move_or_copy_it (rhs_it));
119- }
120- else
121- {
122- // When the slot is in the 'FREE' state, it is unsafe to proceed with assignment operation.
123- // Therefore, we need to force helper to use ctor create to make sure that the 'FREE' slots get initialized.
124- Helper::create_new (m_data[i], Helper::move_or_copy_it (rhs_it));
125- }
126-
127- m_status[i] = SlotStatus::USED;
128- m_next[i] = static_cast <IndexType>(i + 1U );
129- }
130-
131- // reset rest
132- for (; i < CAPACITY; ++i)
133- {
134- if (m_status[i] == SlotStatus::USED)
135- {
136- m_data[i].~T ();
137- }
138-
139- m_status[i] = SlotStatus::FREE;
140-
141- auto next = static_cast <IndexType>(i + 1U );
142- m_next[i] = next;
143- }
144-
145- // correct m_next
146- m_next[Index::LAST] = Index::INVALID;
147- if (!rhs.empty ())
148- {
149- m_next[rhs.m_size - 1 ] = Index::INVALID;
150- }
151-
152- m_begin_free = static_cast <IndexType>(rhs.m_size );
153- m_begin_used = rhs.empty () ? Index::INVALID : Index::FIRST;
154- m_size = rhs.m_size ;
155-
156- // reset rhs if is_move is true
157- if constexpr (is_move)
158- {
159- rhs.clear ();
160- }
161- }
162- #else
16390template <typename T, uint64_t CAPACITY>
16491template <MoveAndCopyOperations Opt, typename RhsType>
16592inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rhs) noexcept
@@ -171,7 +98,11 @@ inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rh
17198 constexpr bool is_move = Helper::is_move;
17299
173100 // status array is not yet initialized for constructor creation
101+ #if IOX_HOOFS_SUBSET
174102 if (is_ctor)
103+ #else
104+ if constexpr (is_ctor)
105+ #endif
175106 {
176107 for (IndexType i = 0 ; i < CAPACITY; ++i)
177108 {
@@ -227,12 +158,15 @@ inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rh
227158 m_size = rhs.m_size ;
228159
229160 // reset rhs if is_move is true
161+ #if IOX_HOOFS_SUBSET
230162 if (is_move)
163+ #else
164+ if constexpr (is_move)
165+ #endif
231166 {
232167 rhs.clear ();
233168 }
234169}
235- #endif
236170
237171template <typename T, uint64_t CAPACITY>
238172inline void FixedPositionContainer<T, CAPACITY>::clear() noexcept
0 commit comments