[libc++][ranges] Fix `ranges::to` test.
authorKonstantin Varlamov <varconsteq@gmail.com>
Thu, 27 Jul 2023 22:24:15 +0000 (15:24 -0700)
committerTobias Hieta <tobias@hieta.se>
Sun, 27 Aug 2023 08:55:24 +0000 (10:55 +0200)
- Make a test for an internal concept libc++-only;
- Make sure that `size` and `capacity` in a test container return the
  same type on all platforms.

(cherry picked from commit 8b9a98661b780a5b50d1d6a1f822d25e0c454382)

libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp

index 75f55bc..03270f2 100644 (file)
@@ -19,6 +19,7 @@
 #include <vector>
 #include "container.h"
 #include "test_iterators.h"
+#include "test_macros.h"
 #include "test_range.h"
 
 template <class Container, class Range, class... Args>
@@ -119,6 +120,7 @@ struct Fallback {
   constexpr void push_back(value_type) {}
   constexpr value_type* begin() { return &x; }
   constexpr value_type* end() { return &x; }
+  std::size_t size() const { return 0; }
 };
 
 struct CtrDirectOrFallback : Fallback {
@@ -180,7 +182,7 @@ struct Reservable : Fallback {
     reserve_called = true;
   }
 };
-static_assert(std::ranges::__reservable_container<Reservable<>>);
+LIBCPP_STATIC_ASSERT(std::ranges::__reservable_container<Reservable<>>);
 
 constexpr void test_constraints() {
   { // Case 1 -- construct directly from the range.