Function constrain

Synopsis

#include <include/type_safe/constrained_type.hpp>

constexpr Constraint auto constrain(T &&value, Constraint c) -> constrained_type< typename std::decay< T >::type, Constraint, Verifier >

Description

Creates a [ts::constrained_type]() with the default verifier, [ts::assertion_verifier]().

Returns
A [ts::constrained_type]() with the given value and Constraint. \requires As it uses a DEBUG_ASSERT to check constrain, the value must be valid. \unique_name constrain

Source

Lines 448-455 in include/type_safe/constrained_type.hpp.

template <class Verifier, typename T, typename Constraint>
constexpr auto constrain(T&& value, Constraint c)
    -> constrained_type<typename std::decay<T>::type, Constraint, Verifier>
{
    return constrained_type<typename std::decay<T>::type, Constraint, Verifier>(std::forward<T>(
                                                                                    value),
                                                                                std::move(c));
}





Add Discussion as Guest

Log in