Skip to content

Commit

Permalink
add push_back(T&&) overload and no-op shrink_to_fit in basic_vector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
maichmueller authored Dec 5, 2024
1 parent c0a48d8 commit 989b7d5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/cista/containers/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ struct basic_vector {
++used_size_;
}

void push_back(T&& el) {
reserve(used_size_ + 1U);
new (el_ + used_size_) T(std::move(el));
++used_size_;
}

template <typename... Args>
T& emplace_back(Args&&... el) {
reserve(used_size_ + 1U);
Expand All @@ -322,6 +328,8 @@ struct basic_vector {
used_size_ = size;
}

void shrink_to_fit() {}

void pop_back() noexcept(noexcept(std::declval<T>().~T())) {
--used_size_;
el_[used_size_].~T();
Expand Down

0 comments on commit 989b7d5

Please sign in to comment.