summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-08-05 10:52:54 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2022-08-22 16:25:53 +0200
commit02c067dee5b53ca318f3acd245795172a0280f1f (patch)
treeec5d2af388fe5fa026ae2576c7f96fe843b26674
parent7037cfc0f48739bd1eb3498827ebf501671302c7 (diff)
downloadcmake-02c067dee5b53ca318f3acd245795172a0280f1f.tar.gz
cm::enum_set: fix various bugs
-rw-r--r--Tests/CMakeLib/testCMExtEnumSet.cxx9
-rw-r--r--Utilities/std/cmext/enum_set13
2 files changed, 17 insertions, 5 deletions
diff --git a/Tests/CMakeLib/testCMExtEnumSet.cxx b/Tests/CMakeLib/testCMExtEnumSet.cxx
index 64c437b295..dbb0a542eb 100644
--- a/Tests/CMakeLib/testCMExtEnumSet.cxx
+++ b/Tests/CMakeLib/testCMExtEnumSet.cxx
@@ -191,6 +191,15 @@ void testEdition()
++failed;
}
}
+ {
+ cm::enum_set<Test> testSet1;
+ cm::enum_set<Test> testSet2{ Test::A, Test::C, Test::B };
+
+ testSet1 = { Test::A, Test::C, Test::B };
+ if (testSet1.size() != 3 || testSet1 != testSet2) {
+ ++failed;
+ }
+ }
}
}
diff --git a/Utilities/std/cmext/enum_set b/Utilities/std/cmext/enum_set
index 4225b825ab..d7b8b39b8e 100644
--- a/Utilities/std/cmext/enum_set
+++ b/Utilities/std/cmext/enum_set
@@ -146,6 +146,7 @@ public:
{
this->Set.reset();
this->insert(list);
+ return *this;
}
// Iterators
@@ -298,17 +299,15 @@ public:
{
if (this->contains(e)) {
return iterator(this, static_cast<size_type>(e));
- } else {
- return this->end();
}
+ return this->end();
}
const_iterator find(key_type e) const
{
if (this->contains(e)) {
return const_iterator(this, static_cast<size_type>(e));
- } else {
- return this->end();
}
+ return this->end();
}
bool contains(key_type e) const
@@ -317,6 +316,10 @@ public:
}
private:
+ template <typename E>
+ friend inline bool operator==(const enum_set<E>& lhs,
+ const enum_set<E>& rhs) noexcept;
+
template <typename E, typename Predicate>
friend inline void erase_if(enum_set<E>& set, Predicate pred);
@@ -369,7 +372,7 @@ template <typename Enum>
inline bool operator==(const enum_set<Enum>& lhs,
const enum_set<Enum>& rhs) noexcept
{
- return lhs == rhs;
+ return lhs.Set == rhs.Set;
}
template <typename Enum>