[libcxx-commits] [libcxx] [libc++] Slightly simplify max_size and add new tests for vector (PR #119990)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 29 09:39:37 PST 2025
================
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// size_type max_size() const;
+
+#include <algorithm>
+#include <cassert>
+#include <climits>
+#include <cstdint>
+#include <limits>
+#include <memory>
+#include <type_traits>
+#include <vector>
+
+#include "min_allocator.h"
+#include "sized_allocator.h"
+#include "test_allocator.h"
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+
+template <typename Alloc>
+TEST_CONSTEXPR_CXX20 void test(const std::vector<bool, Alloc>& v) {
+ using Vector = std::vector<bool, Alloc>;
+ using size_type = typename Vector::size_type;
+ using difference_type = typename Vector::difference_type;
+ using storage_type = typename Vector::__storage_type;
----------------
ldionne wrote:
This alias only exists in libc++, and our test suite must be portable. I suspect this means you will need to significantly weaken the tests for non-libc++ implementations, and that's okay. But the tests should still work on non-libc++ implementations.
https://github.com/llvm/llvm-project/pull/119990
More information about the libcxx-commits
mailing list