Skip to content

Commit

Permalink
mutable_fws_multimap::insert -> return iterator instead of ref
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Jun 1, 2023
1 parent 8c090ea commit b1db434
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions include/cista/containers/mutable_fws_multimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,17 @@ struct dynamic_fws_multimap_base {
}

template <bool IsConst = Const, typename = std::enable_if_t<!IsConst>>
void insert(iterator it, value_type const& val) {
prepare_insert(it) = val;
iterator insert(iterator it, value_type const& val) {
auto insert_it = prepare_insert(it);
*insert_it = val;
return insert_it;
}

template <bool IsConst = Const, typename = std::enable_if_t<!IsConst>>
void insert(iterator it, value_type&& val) {
prepare_insert(it) = std::move(val);
iterator insert(iterator it, value_type&& val) {
auto insert_it = prepare_insert(it);
*insert_it = std::move(val);
return insert_it;
}

template <bool IsConst = Const, typename = std::enable_if_t<!IsConst>>
Expand Down Expand Up @@ -242,15 +246,15 @@ struct dynamic_fws_multimap_base {
}

template <bool IsConst = Const, typename = std::enable_if_t<!IsConst>>
value_type& prepare_insert(bucket::iterator it) {
iterator prepare_insert(bucket::iterator it) {
auto const pos = std::distance(begin(), it);
auto& index = get_index();
reserve(index.size_ + 1U);
it = std::next(begin(), pos);
std::move_backward(it, end(), std::next(end()));
++index.size_;
++mutable_mm().element_count_;
return *it;
return it;
}

dynamic_fws_multimap_base& mutable_mm() noexcept {
Expand Down

0 comments on commit b1db434

Please sign in to comment.