From d5b1ca1a52b6406458358a7fcf91b5014ad31d2c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 14 Aug 2023 15:26:10 +0200 Subject: [PATCH] util/StaticVector: use emplace_back() to implement push_back() For this class, both are equal. --- src/util/StaticVector.hxx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/util/StaticVector.hxx b/src/util/StaticVector.hxx index 010be97d2..838e21485 100644 --- a/src/util/StaticVector.hxx +++ b/src/util/StaticVector.hxx @@ -192,19 +192,11 @@ public: } constexpr void push_back(const_reference value) { - if (full()) - throw std::bad_alloc{}; - - ::new(&array[the_size]) T(value); - ++the_size; + emplace_back(value); } constexpr void push_back(T &&value) { - if (full()) - throw std::bad_alloc{}; - - ::new(&array[the_size]) T(std::move(value)); - ++the_size; + emplace_back(std::move(value)); } template