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

Function enum_prev_value

include/magic_enum/magic_enum_utility.hpp:109–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107
108template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
109[[nodiscard]] constexpr auto enum_prev_value(E value, std::ptrdiff_t n = 1) noexcept -> detail::enable_if_t<E, optional<std::decay_t<E>>> {
110 using D = std::decay_t<E>;
111 constexpr std::ptrdiff_t count = detail::count_v<D, S>;
112
113 if (const auto i = enum_index<D, S>(value)) {
114 const std::ptrdiff_t index = (static_cast<std::ptrdiff_t>(*i) - n);
115 if (index >= 0 && index < count) {
116 return enum_value<D, S>(static_cast<std::size_t>(index));
117 }
118 }
119 return {};
120}
121
122template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
123[[nodiscard]] constexpr auto enum_prev_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