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
1 changed files with 9 additions and 4 deletions

View File

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