Skip to content

Commit 76bb94f

Browse files
committed
wip
1 parent 40a4897 commit 76bb94f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

include/type_safe/flag_set.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ class flag_set
559559
return flags_.to_int();
560560
}
561561

562+
template <typename UnaryFunction>
563+
constexpr void for_each(UnaryFunction f) {
564+
auto m = flags_.to_int();
565+
using U = decltype(m);
566+
for (U i = 0; i < std::numeric_limits<U>::digits; ++i) {
567+
if ((m & (U{1} << i)) != U{0}) {
568+
f(static_cast<Enum>(i));
569+
}
570+
}
571+
}
572+
562573
//=== bitwise operations ===//
563574
/// \returns A set with all the flags flipped.
564575
constexpr flag_set operator~() const noexcept

0 commit comments

Comments
 (0)