From 02c067dee5b53ca318f3acd245795172a0280f1f Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 5 Aug 2022 10:52:54 +0200 Subject: cm::enum_set: fix various bugs --- Tests/CMakeLib/testCMExtEnumSet.cxx | 9 +++++++++ Utilities/std/cmext/enum_set | 13 ++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Tests/CMakeLib/testCMExtEnumSet.cxx b/Tests/CMakeLib/testCMExtEnumSet.cxx index 64c437b..dbb0a54 100644 --- a/Tests/CMakeLib/testCMExtEnumSet.cxx +++ b/Tests/CMakeLib/testCMExtEnumSet.cxx @@ -191,6 +191,15 @@ void testEdition() ++failed; } } + { + cm::enum_set testSet1; + cm::enum_set 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 4225b82..d7b8b39 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(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(e)); - } else { - return this->end(); } + return this->end(); } bool contains(key_type e) const @@ -317,6 +316,10 @@ public: } private: + template + friend inline bool operator==(const enum_set& lhs, + const enum_set& rhs) noexcept; + template friend inline void erase_if(enum_set& set, Predicate pred); @@ -369,7 +372,7 @@ template inline bool operator==(const enum_set& lhs, const enum_set& rhs) noexcept { - return lhs == rhs; + return lhs.Set == rhs.Set; } template -- cgit v0.12