-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[ADT] Add a range constructor to SmallSetVector #132645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADT] Add a range constructor to SmallSetVector #132645
Conversation
DenseSet recently gained a range constructor: DenseSet<T> Dest(llvm::from_range, Src); This patch adds the same signature to SmallSetVector for consistency.
|
@llvm/pr-subscribers-llvm-adt Author: Kazu Hirata (kazutakahirata) ChangesDenseSet recently gained a range constructor: DenseSet<T> Dest(llvm::from_range, Src); This patch adds the same signature to SmallSetVector for consistency. Full diff: https://github.com/llvm/llvm-project/pull/132645.diff 2 Files Affected:
diff --git a/llvm/include/llvm/ADT/SetVector.h b/llvm/include/llvm/ADT/SetVector.h
index 6ee9375b175b7..0692071adb391 100644
--- a/llvm/include/llvm/ADT/SetVector.h
+++ b/llvm/include/llvm/ADT/SetVector.h
@@ -386,6 +386,10 @@ class SmallSetVector : public SetVector<T, SmallVector<T, N>, DenseSet<T>, N> {
SmallSetVector(It Start, It End) {
this->insert(Start, End);
}
+
+ template <typename Range>
+ SmallSetVector(llvm::from_range_t, Range &&R)
+ : SmallSetVector(adl_begin(R), adl_end(R)) {}
};
} // end namespace llvm
diff --git a/llvm/unittests/ADT/SetVectorTest.cpp b/llvm/unittests/ADT/SetVectorTest.cpp
index 6ce4360cab90e..ff3c876deb458 100644
--- a/llvm/unittests/ADT/SetVectorTest.cpp
+++ b/llvm/unittests/ADT/SetVectorTest.cpp
@@ -100,3 +100,9 @@ TEST(SetVector, InsertRange) {
Set.insert_range(Args);
EXPECT_THAT(Set, ::testing::ElementsAre(3, 1, 2));
}
+
+TEST(SmallSetVector, CtorRange) {
+ constexpr unsigned Args[] = {3, 1, 2};
+ SmallSetVector<unsigned, 4> Set(llvm::from_range, Args);
+ EXPECT_THAT(Set, ::testing::ElementsAre(3, 1, 2));
+}
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/18742 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/8483 Here is the relevant piece of the build log for the reference |
DenseSet recently gained a range constructor:
DenseSet Dest(llvm::from_range, Src);
This patch adds the same signature to SmallSetVector for consistency.