Class compact_integer_policy

Synopsis

#include <include/type_safe/compact_optional.hpp>

template <typename Integer, Integer Invalid>
class compact_integer_policy

Description

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

The given Invalid value will be used to mark an empty optional.

Methods

invalid_value
is_invalid

Source

Lines 222-240 in include/type_safe/compact_optional.hpp.

template <typename Integer, Integer Invalid>
class compact_integer_policy
{
    static_assert(std::is_integral<Integer>::value, "must be an integral value");

public:
    using value_type   = Integer;
    using storage_type = Integer;

    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