Struct flag_set_traits


#include <include/type_safe/flag_set.hpp>

template <typename Enum>
struct flag_set_traits : detail::is_flag_set<Enum>


Traits for the enum used in a [ts::flag_set]().

For each enum that should be used with [ts::flag_set]() it must provide the following interface:

  • Inherit from [std::true_type]().
  • static constexpr std::size_t size() that returns the number of enumerators.

The default specialization automatically works for enums that have an enumerator _flag_set_size, whose value is the number of enumerators. But you can also specialize the traits for your own enums. Enums which work with [ts::flag_set]() are called flags.

\requires For all specializations the enum must be contiguous starting at 0, simply don't set an explicit value to the enumerators.


Ancestors: is_flag_set

Decsendents: is_flag_combo< flag_combo< Enum >, Enum >, is_flag_combo< Enum, Enum >




Lines 55-62 in include/type_safe/flag_set.hpp.

template <typename Enum>
struct flag_set_traits : detail::is_flag_set<Enum>
    static constexpr std::size_t size() noexcept
        return detail::flag_set_size<Enum>();

Add Discussion as Guest

Log in