[libc++][test] Make EvilContainer a sequence container#178626
Merged
frederick-vs-ja merged 1 commit intollvm:mainfrom Jan 29, 2026
Merged
[libc++][test] Make EvilContainer a sequence container#178626frederick-vs-ja merged 1 commit intollvm:mainfrom
EvilContainer a sequence container#178626frederick-vs-ja merged 1 commit intollvm:mainfrom
Conversation
In tests for flat container adaptors, the `EvilContainer` type doesn't have sufficient constructors to meet the requirements for sequence containers (sequence.reqmts). Also, assignment from an `initializer_list` doesn't have correct return type. This patch make `EvilContainer` inherit constructors from `vector<int>` and add a correct assignment operator from `initializer_list<int>`.
Member
|
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesIn tests for flat container adaptors, the This patch makes Fixes #178624. Full diff: https://github.com/llvm/llvm-project/pull/178626.diff 4 Files Affected:
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
index cb7e30c2b74fa..e56cb12d9a113 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
@@ -27,6 +27,8 @@
static int countdown = 0;
struct EvilContainer : std::vector<int> {
+ using std::vector<int>::vector;
+
EvilContainer() = default;
EvilContainer(EvilContainer&& rhs) {
// Throw on move-construction.
@@ -36,6 +38,11 @@ struct EvilContainer : std::vector<int> {
throw 42;
}
}
+
+ EvilContainer& operator=(std::initializer_list<int> il) {
+ std::vector<int>::operator=(il);
+ return *this;
+ }
};
int main(int, char**) {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp
index c2085e32be532..44b6e93114c78 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp
@@ -27,6 +27,8 @@
static int countdown = 0;
struct EvilContainer : std::vector<int> {
+ using std::vector<int>::vector;
+
EvilContainer() = default;
EvilContainer(EvilContainer&& rhs) {
// Throw on move-construction.
@@ -36,6 +38,11 @@ struct EvilContainer : std::vector<int> {
throw 42;
}
}
+
+ EvilContainer& operator=(std::initializer_list<int> il) {
+ std::vector<int>::operator=(il);
+ return *this;
+ }
};
int main(int, char**) {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
index 064baa98d2b51..f9fea737254d3 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
@@ -159,6 +159,8 @@ void test_move_noexcept() {
static int countdown = 0;
struct EvilContainer : std::vector<int> {
+ using std::vector<int>::vector;
+
EvilContainer() = default;
EvilContainer(EvilContainer&& rhs) {
// Throw on move-construction.
@@ -168,6 +170,11 @@ struct EvilContainer : std::vector<int> {
throw 42;
}
}
+
+ EvilContainer& operator=(std::initializer_list<int> il) {
+ std::vector<int>::operator=(il);
+ return *this;
+ }
};
void test_move_exception() {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
index b737a5fba056d..1d7a3589cc109 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
@@ -150,6 +150,8 @@ constexpr bool test() {
static int countdown = 0;
struct EvilContainer : std::vector<int> {
+ using std::vector<int>::vector;
+
EvilContainer() = default;
EvilContainer(EvilContainer&& rhs) {
// Throw on move-construction.
@@ -159,6 +161,11 @@ struct EvilContainer : std::vector<int> {
throw 42;
}
}
+
+ EvilContainer& operator=(std::initializer_list<int> il) {
+ std::vector<int>::operator=(il);
+ return *this;
+ }
};
void test_move_exception() {
|
philnik777
approved these changes
Jan 29, 2026
honeygoyal
pushed a commit
to honeygoyal/llvm-project
that referenced
this pull request
Jan 30, 2026
In tests for flat container adaptors, the `EvilContainer` type doesn't have sufficient constructors to meet the requirements for sequence containers ([sequence.reqmts]). Also, assignment from an `initializer_list` doesn't have correct return type. This patch makes `EvilContainer` inherit constructors from `vector<int>` and add a correct assignment operator from `initializer_list<int>`.
This was referenced Jan 30, 2026
sshrestha-aa
pushed a commit
to sshrestha-aa/llvm-project
that referenced
this pull request
Feb 4, 2026
In tests for flat container adaptors, the `EvilContainer` type doesn't have sufficient constructors to meet the requirements for sequence containers ([sequence.reqmts]). Also, assignment from an `initializer_list` doesn't have correct return type. This patch makes `EvilContainer` inherit constructors from `vector<int>` and add a correct assignment operator from `initializer_list<int>`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In tests for flat container adaptors, the
EvilContainertype doesn't have sufficient constructors to meet the requirements for sequence containers ([sequence.reqmts]). Also, assignment from aninitializer_listdoesn't have correct return type.This patch makes
EvilContainerinherit constructors fromvector<int>and add a correct assignment operator frominitializer_list<int>.Fixes #178624.