Skip to content

Commit

Permalink
[EnumSet] Iterator ctor deduction guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Younes Reda committed Dec 7, 2023
1 parent a637074 commit 5517300
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/fixed_containers/enum_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ class EnumSet
}
};

template <InputIterator InputIt>
EnumSet(InputIt first,
InputIt last) noexcept->EnumSet<typename std::iterator_traits<InputIt>::value_type>;

template <class K, class Predicate>
constexpr typename EnumSet<K>::size_type erase_if(EnumSet<K>& c, Predicate predicate)
{
Expand Down
7 changes: 7 additions & 0 deletions test/enum_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ TEST(EnumSet, IteratorConstructor)
static_assert(s1.contains(TestEnum1::FOUR));
}

TEST(EnumSet, DeducedIteratorConstructor)
{
constexpr std::array INPUT{TestEnum1::TWO, TestEnum1::FOUR};
constexpr EnumSet s1(INPUT.begin(), INPUT.end());
(void)s1;
}

TEST(EnumSet, InitializerConstructor)
{
constexpr EnumSet<TestEnum1> s1{TestEnum1::TWO, TestEnum1::FOUR};
Expand Down

0 comments on commit 5517300

Please sign in to comment.