[llvm] [LLVM][ADT] Explicitly convert size_t values to SmallVector's size type (PR #77939)
Andrei Golubev via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 05:31:42 PST 2024
================
@@ -100,7 +100,18 @@ template <class Size_T> class SmallVectorBase {
/// This does not construct or destroy any elements in the vector.
void set_size(size_t N) {
assert(N <= capacity());
- Size = N;
+ Size = static_cast<Size_T>(N);
+ assert(size() == N);
+ }
+
+ /// Set the array capacity to \p M, which the current array size must
+ /// not be greater than.
+ ///
+ /// This does not construct or destroy any elements in the vector.
+ void set_capacity(size_t M) {
+ assert(size() <= M);
----------------
andrey-golubev wrote:
> assert(M <= SizeTypeMax());
btw, I guess this could be added to `set_size()` as well. then equality check (`size() == N`) at the end also gets superseded?
https://github.com/llvm/llvm-project/pull/77939
More information about the llvm-commits
mailing list