Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/type_safe/flag_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,18 @@ class flag_set
return flags_.to_int();
}

template <typename UnaryFunction>
TYPE_SAFE_CONSTEXPR14 UnaryFunction for_each(UnaryFunction f) const {
using int_type = typename detail::flag_set_impl<Enum>::int_type;
int_type m = flags_.to_int();
for (int_type i = 0; i < std::numeric_limits<int_type>::digits; ++i) {
if ((m & int_type(int_type(1u) << i)) != int_type(0u)) {
f(static_cast<Enum>(i));
}
}
return f;
}

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