util/StaticVector: add method pop_back()

This commit is contained in:
Max Kellermann 2023-08-14 15:02:28 +02:00 committed by Max Kellermann
parent b2acf02af9
commit a2f4fb9ddb

View File

@ -115,10 +115,8 @@ public:
/* we don't need to call any destructor */ /* we don't need to call any destructor */
the_size = 0; the_size = 0;
} else { } else {
while (!empty()) { while (!empty())
back().~T(); pop_back();
--the_size;
}
} }
} }
@ -207,4 +205,11 @@ public:
::new(&array[the_size]) T(std::forward<Args>(args)...); ::new(&array[the_size]) T(std::forward<Args>(args)...);
return *Launder(&array[the_size++]); return *Launder(&array[the_size++]);
} }
constexpr void pop_back() noexcept {
assert(!empty());
back().~T();
--the_size;
}
}; };