Class non_empty

Synopsis

#include <include/type_safe/constrained_type.hpp>

class non_empty

Description

A Constraint for the [ts::constrained_type]().

A value of a container type is valid if it is not empty. Empty-ness is determined with either a member or non-member function.

Mentioned in

Methods

operator()

Source

Lines 563-584 in include/type_safe/constrained_type.hpp.

class non_empty
{
    template <typename T>
    constexpr auto is_empty(int, const T& t) const noexcept(noexcept(t.empty()))
        -> decltype(t.empty())
    {
        return !t.empty();
    }
    template <typename T>
    constexpr bool is_empty(short, const T& t) const
    {
        return !empty(t);
    }
public:
    template <typename T>
    constexpr bool operator()(const T& t) const
    {
        return is_empty(0, t);
    }
};





Add Discussion as Guest

Log in