Class compact_container_policy

Synopsis

#include <include/type_safe/compact_optional.hpp>

template <class Container>
class compact_container_policy

Description

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

A Container is a type with a cheap no-throwing default constructor initializing it empty, and either an empty() member function or ADL function that returns true if the container is empty, false otherwise. An empty container will be marked as an empty optional. \module optional

Methods

invalid_value
is_invalid

Source

Lines 326-342 in include/type_safe/compact_optional.hpp.

template <class Container>
class compact_container_policy
{
public:
    using value_type   = Container;
    using storage_type = Container;

    static storage_type invalid_value() noexcept
    {
        return {};
    }

    static bool is_invalid(const storage_type& storage) noexcept
    {
        return static_cast<bool>(detail::is_empty(0, storage));
    }
};





Add Discussion as Guest

Log in