Class compact_enum_policy

Synopsis

#include <include/type_safe/compact_optional.hpp>

template <typename Enum, compact_enum_detail::underlying_type<Enum> Invalid>
class compact_enum_policy

Description

A CompactPolicy for [ts::compact_optional_storage]() for enumeration types.

It uses the given Invalid value of the underlying type to mark an empty optional. \notes It uses a different storage_type and thus cannot return a reference to the stored value. \module optional

Methods

invalid_value
is_invalid

Source

Lines 286-302 in include/type_safe/compact_optional.hpp.

template <typename Enum, compact_enum_detail::underlying_type<Enum> Invalid>
class compact_enum_policy
{
public:
    using value_type   = Enum;
    using storage_type = compact_enum_detail::underlying_type<Enum>;

    static storage_type invalid_value() noexcept
    {
        return Invalid;
    }

    static bool is_invalid(const storage_type& storage) noexcept
    {
        return storage == Invalid;
    }
};





Add Discussion as Guest

Log in