Skip to content

Conversation

AlexGuteniev
Copy link
Contributor

Continues #140287

from_range_t constructor is needed by MSVC STL to pass std/containers/container.adaptors/flat.set/flat.set.cons/range.pass.cpp.

The rest are added to complete the container according to #140287 (review).

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner September 12, 2025 18:34
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 12, 2025

@llvm/pr-subscribers-libcxx

Author: Alex Guteniev (AlexGuteniev)

Changes

Continues #140287

from_range_t constructor is needed by MSVC STL to pass std/containers/container.adaptors/flat.set/flat.set.cons/range.pass.cpp.

The rest are added to complete the container according to #140287 (review).


Full diff: https://github.com/llvm/llvm-project/pull/158344.diff

1 Files Affected:

  • (modified) libcxx/test/support/MinSequenceContainer.h (+18)
diff --git a/libcxx/test/support/MinSequenceContainer.h b/libcxx/test/support/MinSequenceContainer.h
index 9af5847f08871..8433ebb39160c 100644
--- a/libcxx/test/support/MinSequenceContainer.h
+++ b/libcxx/test/support/MinSequenceContainer.h
@@ -29,6 +29,12 @@ struct MinSequenceContainer {
   template <class It>
   explicit TEST_CONSTEXPR_CXX20 MinSequenceContainer(It first, It last) : data_(first, last) {}
   TEST_CONSTEXPR_CXX20 MinSequenceContainer(std::initializer_list<T> il) : data_(il) {}
+  template <class Range>
+  TEST_CONSTEXPR_CXX20 MinSequenceContainer(std::from_range_t, Range&& rg)
+      : data_(std::from_range, std::forward<Range>(rg)) {}
+  TEST_CONSTEXPR_CXX20 MinSequenceContainer(size_type n, T value) : data_(n, value) {}
+
+  MinSequenceContainer& operator=(std::initializer_list<T> il) { data_ = il; }
 
   template <class It>
   TEST_CONSTEXPR_CXX20 void assign(It first, It last) {
@@ -36,6 +42,10 @@ struct MinSequenceContainer {
   }
   TEST_CONSTEXPR_CXX20 void assign(std::initializer_list<T> il) { data_.assign(il); }
   TEST_CONSTEXPR_CXX20 void assign(size_type n, value_type t) { data_.assign(n, t); }
+  template <class Range>
+  TEST_CONSTEXPR_CXX20 void assign_range(Range&& rg) {
+    data_.assign_range(std::forward<Range>(rg));
+  }
   TEST_CONSTEXPR_CXX20 iterator begin() { return iterator(data_.data()); }
   TEST_CONSTEXPR_CXX20 const_iterator begin() const { return const_iterator(data_.data()); }
   TEST_CONSTEXPR_CXX20 const_iterator cbegin() const { return const_iterator(data_.data()); }
@@ -55,6 +65,14 @@ struct MinSequenceContainer {
     return from_vector_iterator(data_.insert(to_vector_iterator(p), std::move(value)));
   }
 
+  TEST_CONSTEXPR_CXX20 iterator insert(const_iterator p, size_type n, T value) {
+    return from_vector_iterator(data_.insert(to_vector_iterator(p), n, value));
+  }
+
+  TEST_CONSTEXPR_CXX20 iterator insert(const_iterator p, std::initializer_list<T> il) {
+    return from_vector_iterator(data_.insert(to_vector_iterator(p), il));
+  }
+
   template <class Range>
   TEST_CONSTEXPR_CXX20 iterator insert_range(const_iterator p, Range&& rg) {
     return from_vector_iterator(data_.insert_range(to_vector_iterator(p), std::forward<Range>(rg)));

Comment on lines +32 to +34
template <class Range>
TEST_CONSTEXPR_CXX20 MinSequenceContainer(std::from_range_t, Range&& rg)
: data_(std::from_range, std::forward<Range>(rg)) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that this should be guard with TEST_STD_VER >= 23 and unconditionally constexpr. Ditto assign_range.

No change requested as there's no new error, and perhaps we can do clean-up in the future. CI failures are unrelated.

@frederick-vs-ja frederick-vs-ja merged commit a7c963a into llvm:main Sep 13, 2025
72 of 80 checks passed
@AlexGuteniev AlexGuteniev deleted the flat-tests-min-seq-23 branch September 13, 2025 17:52
ldionne pushed a commit that referenced this pull request Sep 15, 2025
Follows-up #158344.

- Guard range-related functions with `TEST_STD_VER >= 23`.
- Mark range-related functions unconditionally `constexpr`.
- Add `TEST_CONSTEXPR_CXX20` to one `operator=`.

This will make `MinSequenceContainer` more consistent and useful for
legacy container adaptors or C++26 `constexpr` additions. Although we're
currently only using it with flat container adaptors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants