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

Function is_valid

include/magic_enum/magic_enum.hpp:682–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680
681template <typename E, auto V>
682constexpr bool is_valid() noexcept {
683 if constexpr (is_enum_constexpr_static_cast_valid<E, V>) {
684 constexpr E v = static_cast<E>(V);
685 [[maybe_unused]] constexpr auto custom = customize::enum_name<E>(v);
686 static_assert(std::is_same_v<std::decay_t<decltype(custom)>, customize::customize_t>, "magic_enum::customize requires customize_t type.");
687 if constexpr (custom.first == customize::detail::customize_tag::custom_tag) {
688 constexpr auto name = custom.second;
689 static_assert(!name.empty(), "magic_enum::customize requires not empty string.");
690 return name.size() != 0;
691 } else if constexpr (custom.first == customize::detail::customize_tag::default_tag) {
692#if defined(MAGIC_ENUM_VS_2017_WORKAROUND)
693 return n<E, v>().size_ != 0;
694#else
695 return n<v>().size_ != 0;
696#endif
697 } else {
698 return false;
699 }
700 } else {
701 return false;
702 }
703}
704
705enum class enum_subtype {
706 common,

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected