Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Neargye committed Jun 23, 2020
1 parent 40a4897 commit 76bb94f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/type_safe/flag_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,17 @@ class flag_set
return flags_.to_int();
}

template <typename UnaryFunction>
constexpr void for_each(UnaryFunction f) {
auto m = flags_.to_int();
using U = decltype(m);
for (U i = 0; i < std::numeric_limits<U>::digits; ++i) {
if ((m & (U{1} << i)) != U{0}) {
f(static_cast<Enum>(i));
}
}
}

//=== bitwise operations ===//
/// \returns A set with all the flags flipped.
constexpr flag_set operator~() const noexcept
Expand Down

0 comments on commit 76bb94f

Please sign in to comment.