MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / enum_value

Function enum_value

include/behaviortree_cpp/contrib/magic_enum.hpp:1176–1187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1174// No bounds checking is performed: the behavior is undefined if index >= number of enum values.
1175template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
1176[[nodiscard]] constexpr auto enum_value(std::size_t index) noexcept -> detail::enable_if_t<E, std::decay_t<E>> {
1177 using D = std::decay_t<E>;
1178 static_assert(detail::is_reflected_v<D, S>, "magic_enum requires enum implementation and valid max and min.");
1179
1180 if constexpr (detail::is_sparse_v<D, S>) {
1181 return MAGIC_ENUM_ASSERT(index < detail::count_v<D, S>), detail::values_v<D, S>[index];
1182 } else {
1183 constexpr auto min = (S == detail::enum_subtype::flags) ? detail::log2(detail::min_v<D, S>) : detail::min_v<D, S>;
1184
1185 return MAGIC_ENUM_ASSERT(index < detail::count_v<D, S>), detail::value<D, min, S>(index);
1186 }
1187}
1188
1189// Returns enum value at specified index.
1190template <typename E, std::size_t I, detail::enum_subtype S = detail::subtype_v<E>>

Callers

nothing calls this directly

Calls 1

log2Function · 0.85

Tested by

no test coverage detected