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

Function enum_next_value

include/magic_enum/magic_enum_utility.hpp:81–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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>>> {
82 using D = std::decay_t<E>;
83 constexpr std::ptrdiff_t count = detail::count_v<D, S>;
84
85 if (const auto i = enum_index<D, S>(value)) {
86 const std::ptrdiff_t index = (static_cast<std::ptrdiff_t>(*i) + n);
87 if (index >= 0 && index < count) {
88 return enum_value<D, S>(static_cast<std::size_t>(index));
89 }
90 }
91 return {};
92}
93
94template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
95[[nodiscard]] constexpr auto enum_next_value_circular(E value, std::ptrdiff_t n = 1) noexcept -> detail::enable_if_t<E, std::decay_t<E>> {

Callers 2

test_flags.cppFile · 0.85
test.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected