Skip to content

Add public is_flags type trait #447

@jannejy

Description

@jannejy

There is no public API to check at compile time whether an enum has is_flags = true. The only options are accessing detail::has_is_flags (internal) or writing a custom SFINAE trait.

Use case

template <typename E>
std::optional<E> generic_enum_cast(std::string_view sv) {
    if constexpr (magic_enum::is_flags_v<E>) {
        return magic_enum::enum_flags_cast<E>(sv);
    } else {
        return magic_enum::enum_cast<E>(sv);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions