Class compact_bool_policy

Synopsis

#include <include/type_safe/compact_optional.hpp>

template <typename Boolean>
class compact_bool_policy

Description

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

It is designed for either bool or [ts::boolean](). \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 201-217 in include/type_safe/compact_optional.hpp.

template <typename Boolean>
class compact_bool_policy
{
public:
    using value_type   = Boolean;
    using storage_type = char;

    static storage_type invalid_value() noexcept
    {
        return 3;
    }

    static bool is_invalid(storage_type storage) noexcept
    {
        return storage == invalid_value();
    }
};





Add Discussion as Guest

Log in