MCPcopy Create free account
hub / github.com/Neargye/magic_enum / enum_for_each

Function enum_for_each

include/magic_enum/magic_enum_utility.hpp:67–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66template <typename E, detail::enum_subtype S = detail::subtype_v<E>, typename F, detail::enable_if_t<E, int> = 0>
67constexpr auto enum_for_each(F&& f) {
68 using D = std::decay_t<E>;
69 static_assert(std::is_enum_v<D>, "magic_enum::enum_for_each requires enum type.");
70 static_assert(detail::is_reflected_v<D, S>, "magic_enum requires enum implementation and valid max and min.");
71 constexpr auto sep = std::make_index_sequence<detail::count_v<D, S>>{};
72
73 if constexpr (detail::all_invocable<D, S, F>(sep)) {
74 return detail::for_each<D, S>(std::forward<F>(f), sep);
75 } else {
76 static_assert(detail::always_false_v<D>, "magic_enum::enum_for_each requires invocable of all enum value.");
77 }
78}
79
80template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
81[[nodiscard]] constexpr auto enum_next_value(E value, std::ptrdiff_t n = 1) noexcept -> detail::enable_if_t<E, optional<std::decay_t<E>>> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected