Struct non_null

Synopsis

#include <include/type_safe/constrained_type.hpp>

struct non_null

Description

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

A value of a pointer type is valid if it is not equal to nullptr. This is borrowed from GSL's non_null.

Mentioned in

Structures

is_valid
is_valid< std::nullptr_t >

Methods

operator()

Source

Lines 542-553 in include/type_safe/constrained_type.hpp.

struct non_null
{
    template <typename T>
    struct is_valid : std::true_type
    {};
    template <typename T>
    constexpr bool operator()(const T& ptr) const noexcept
    {
        return ptr != nullptr;
    }
};





Add Discussion as Guest

Log in