Function sanitize

Synopsis

#include <include/type_safe/constrained_type.hpp>

template <typename T, typename Constraint>
constexpr auto sanitize(T &&value, Constraint c) -> constrained_type< typename std::decay< T >::type, Constraint, throwing_verifier >

Description

Creates a [ts::constrained_type]() using the [ts::throwing_verifier]().

Returns
A [ts::constrained_type]() with the given value and Constraint.
Exceptions

A - [ts::constrain_error]() if the value isn't valid, or anything else thrown by the constructor. \notes This is meant for sanitizing user input, using a recoverable error handling strategy.

Mentioned in

Source

Lines 476-482 in include/type_safe/constrained_type.hpp.

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





Add Discussion as Guest

Log in