PlayRho  2.0.0
An interactive physics engine & library.
playrho::detail::Checked< ValueType, Checker, NoExcept > Class Template Reference

Class template for construction-time constraining a type's value. More...

#include <playrho/detail/Checked.hpp>

Inheritance diagram for playrho::detail::Checked< ValueType, Checker, NoExcept >:
[legend]

Classes

struct  IsChecked
 Failing is-checked class template trait. More...
 
struct  IsChecked< Checked< V, C, N > >
 Succeeding is-checked class template trait. More...
 

Public Types

using checker_type = Checker
 Alias for checker type this class template was instantiated for.
 
using exception_type = InvalidArgument
 Alias for the exception type possibly thrown by this class.
 
using remove_pointer_type = std::remove_pointer_t< ValueType >
 Alias for the removed pointer type. More...
 
using underlying_type = ValueType
 Alias for the value type this class template was instantiated for.
 

Public Member Functions

template<bool B = HasNullaryFunctor<Checker,ValueType>::value, std::enable_if_t< B, int > = 0>
constexpr Checked () noexcept(NoExcept)
 Default constructor. More...
 
template<class OtherValueType , class OtherChecker , bool OtherNoExcept, std::enable_if_t< std::is_constructible_v< ValueType, OtherValueType > &&!std::is_same_v< Checker, OtherChecker >, int > = 0>
constexpr Checked (const Checked< OtherValueType, OtherChecker, OtherNoExcept > &other) noexcept(NoExcept)
 Copying constructor. More...
 
template<bool OtherNoExcept>
constexpr Checked (const Checked< ValueType, Checker, OtherNoExcept > &other) noexcept
 Copying constructor. More...
 
template<class U = ValueType, std::enable_if_t< std::conjunction_v< std::negation< IsChecked< std::decay_t< U >>>, std::is_constructible< ValueType, U && >, std::negation< is_narrowing_conversion< U, ValueType >> >, bool > = true>
constexpr Checked (U &&value) noexcept(NoExcept)
 Implicit initializing constructor. More...
 
template<class U = ValueType, std::enable_if_t< std::conjunction_v< std::negation< IsChecked< std::decay_t< U >>>, std::is_constructible< ValueType, U && >, is_narrowing_conversion< U, ValueType > >, bool > = false>
constexpr Checked (U &&value) noexcept(NoExcept)
 Explicit initializing constructor. More...
 
constexpr underlying_type get () const noexcept
 Explicitly gets the underlying value. More...
 
template<class U , std::enable_if_t< std::conjunction_v< std::negation< IsChecked< U >>, std::is_constructible< U, ValueType >, std::negation< is_narrowing_conversion< ValueType, U >> >, bool > = true>
constexpr operator U () const noexcept
 Implicitly gets the underlying value via a cast or implicit conversion. More...
 
template<class U , std::enable_if_t< std::conjunction_v< std::negation< IsChecked< U >>, std::is_constructible< U, ValueType >, is_narrowing_conversion< ValueType, U > >, bool > = false>
constexpr operator U () const noexcept
 Explicitly gets the underlying value via a cast or implicit conversion. More...
 
template<class U = ValueType>
constexpr std::enable_if_t< std::is_pointer_v< U >, remove_pointer_type > & operator* () const
 Indirection operator available for pointer ValueType. More...
 
template<class U = ValueType>
constexpr std::enable_if_t< std::is_pointer_v< U >, U > operator-> () const
 Member-of pointer operator available for pointer ValueType. More...
 

Static Public Member Functions

static constexpr auto ThrowIfInvalid (const underlying_type &value) -> decltype((void) exception_type(Checker{}(value)), std::declval< void >())
 Throws this class's exception type if the given value is invalid. More...
 
static constexpr auto Validate (const underlying_type &value) noexcept(NoExcept) -> decltype(ThrowIfInvalid(value), underlying_type{})
 Validator function. More...
 

Related Functions

(Note that these are not member functions.)

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator!= (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) noexcept(noexcept(std::declval< LhsValueType >() !=std::declval< RhsValueType >())) -> decltype(LhsValueType(lhs) !=RhsValueType(rhs))
 Constrained value inequality operator for value types which support it. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator!= (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs) !=rhs)
 Constrained value inequality operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator!= (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(lhs !=ValueType(rhs))
 Constrained value inequality operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator* (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs) *RhsValueType(rhs))
 Constrained value multiplication operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator* (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> std::enable_if_t<!IsMultipliableV< Checked< ValueType, Checker, NoExcept >, Other >, decltype(ValueType() *Other())>
 Constrained value multiplication operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator* (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> std::enable_if_t<!IsMultipliableV< Other, Checked< ValueType, Checker, NoExcept >>, decltype(Other() *ValueType())>
 Constrained value multiplication operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator+ (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs)+RhsValueType(rhs))
 Constrained value addition operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator+ (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs)+rhs)
 Constrained value addition operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator+ (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(lhs+ValueType(rhs))
 Constrained value addition operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator- (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs) - RhsValueType(rhs))
 Constrained value subtraction operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator- (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs) - rhs)
 Constrained value subtraction operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator- (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(lhs - ValueType(rhs))
 Constrained value subtraction operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator/ (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs)/RhsValueType(rhs))
 Constrained value division operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator/ (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs)/rhs)
 Constrained value division operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator/ (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(lhs/ValueType(rhs))
 Constrained value division operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator< (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs)< RhsValueType(rhs))
 Constrained value less-than operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator< (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs)< ValueType(rhs))
 Constrained value less-than operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator< (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(ValueType(lhs)< ValueType(rhs))
 Constrained value less-than operator. More...
 
template<class ValueType , class Checker , bool NoExcept>
auto operator<< (::std::ostream &os, const Checked< ValueType, Checker, NoExcept > &value) -> decltype(os<< ValueType(value))
 Constrained value stream output operator for value types which support it. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator<= (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs)<=RhsValueType(rhs))
 Constrained value less-than or equal-to operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator<= (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs)<=ValueType(rhs))
 Constrained value less-than or equal-to operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator<= (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(ValueType(lhs)<=ValueType(rhs))
 Constrained value less-than or equal-to operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator== (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) noexcept(noexcept(std::declval< LhsValueType >()==std::declval< RhsValueType >())) -> decltype(LhsValueType(lhs)==RhsValueType(rhs))
 Constrained value equality operator for value types which support it. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator== (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs)==rhs)
 Constrained value equality operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator== (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(lhs==ValueType(rhs))
 Constrained value equality operator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator> (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs) > RhsValueType(rhs))
 Constrained value greater-than operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator> (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs) > ValueType(rhs))
 Constrained value greater-than operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator> (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(ValueType(lhs) > ValueType(rhs))
 Constrained value greater-than ooperator. More...
 
template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator>= (const Checked< LhsValueType, LhsChecker, LhsNoExcept > &lhs, const Checked< RhsValueType, RhsChecker, RhsNoExcept > &rhs) -> decltype(LhsValueType(lhs) >=RhsValueType(rhs))
 Constrained value greater-than or equal-to operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator>= (const Checked< ValueType, Checker, NoExcept > &lhs, const Other &rhs) -> decltype(ValueType(lhs) >=ValueType(rhs))
 Constrained value greater-than or equal-to operator. More...
 
template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator>= (const Other &lhs, const Checked< ValueType, Checker, NoExcept > &rhs) -> decltype(ValueType(lhs) >=ValueType(rhs))
 Constrained value greater-than or equal-to operator. More...
 

Detailed Description

template<class ValueType, class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
class playrho::detail::Checked< ValueType, Checker, NoExcept >

Class template for construction-time constraining a type's value.

Note
Conceptually, this is to values what concepts are to types. One difference however, is this - as a mechanism - operates at construction-time rather than compile-time (like concepts do). From a design perspective, this can serve as an efficient and scalable mechanism for defensive/offensive programming or for pre/post conditions of contract oriented programming so long as the value-type this is used with has only value semantics.
The history of contracts in C++ is long and associated proposals are sordid. There doesn't even appear to be sensible consensus on the meaning of "noexcept". OTOH, N4659 18.4.5 clearly states: "Whenever an exception is thrown and the search for a handler (18.3) encounters the outermost block of a function with a non-throwing exception specification, the function std::terminate() is called".
Invariant
The value of an object of this type is always valid for the checker of the type.
Template Parameters
ValueTypeType of the underlying value that will get checked. Note that this is the only template parameter that effects the size of objects of this class.
CheckerChecker type to check or possibly default initialize values with. See the Checkers topic for more information on what checkers are already available or how to design your own. Note that whatever the checker is, it gets constructed only for single use of either its one parameter value checking functor, or its zero parameter default value supplying functor.
NoExceptWhether to terminate or just throw on being invalid. The value chosen is used for some member functions' noexcept specifier as noexcept(NoExcept) . By using the value of true , those functions that would have otherwise thrown an exception, become terminating functions in debug builds or pass-through functions in non-debug builds. As a guide, use false for types to validate data from outside the program (like from the user, as a defensive programming mechanism), or true for types only validating data from within the program (that should be valid, and as an offensive programming mechanism).
See also
https://en.cppreference.com/w/cpp/language/noexcept_spec.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1656r2.html.

Member Typedef Documentation

◆ remove_pointer_type

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
using playrho::detail::Checked< ValueType, Checker, NoExcept >::remove_pointer_type = std::remove_pointer_t<ValueType>

Alias for the removed pointer type.

Note
This is the same as value_type unless it's actually a pointer type in which case then this is the type pointed to.

Constructor & Destructor Documentation

◆ Checked() [1/5]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<bool B = HasNullaryFunctor<Checker,ValueType>::value, std::enable_if_t< B, int > = 0>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::Checked ( )
inlineconstexprnoexcept

Default constructor.

Constructs a defaulted checked type if the checker type has a nullary functor that returns a value which the Validate(const value_type& value) function validates.

Note
This is only available for checker types with acceptable nullary functors.
Postcondition
Calling get() or casting to the underlying type, results in the value given by the checker's nullary functor.
See also
Validate.

◆ Checked() [2/5]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class U = ValueType, std::enable_if_t< std::conjunction_v< std::negation< IsChecked< std::decay_t< U >>>, std::is_constructible< ValueType, U && >, std::negation< is_narrowing_conversion< U, ValueType >> >, bool > = true>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::Checked ( U &&  value)
inlineconstexprnoexcept

Implicit initializing constructor.

Constructs a checked type of the given value if the Validate(const value_type& value) function validates.

Postcondition
Calling get() or casting to the underlying type, results in the value given.
See also
Validate.

◆ Checked() [3/5]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class U = ValueType, std::enable_if_t< std::conjunction_v< std::negation< IsChecked< std::decay_t< U >>>, std::is_constructible< ValueType, U && >, is_narrowing_conversion< U, ValueType > >, bool > = false>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::Checked ( U &&  value)
inlineexplicitconstexprnoexcept

Explicit initializing constructor.

Constructs a checked type of the given value if the Validate(const value_type& value) function validates.

Postcondition
Calling get() or casting to the underlying type, results in the value given.
See also
Validate.

◆ Checked() [4/5]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class OtherValueType , class OtherChecker , bool OtherNoExcept, std::enable_if_t< std::is_constructible_v< ValueType, OtherValueType > &&!std::is_same_v< Checker, OtherChecker >, int > = 0>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::Checked ( const Checked< OtherValueType, OtherChecker, OtherNoExcept > &  other)
inlineconstexprnoexcept

Copying constructor.

Note
This allows copying from other checked values that don't use the same checker.
Postcondition
Calling get() or casting to the underlying type, results in a value that compares equally to the value given.

◆ Checked() [5/5]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<bool OtherNoExcept>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::Checked ( const Checked< ValueType, Checker, OtherNoExcept > &  other)
inlineconstexprnoexcept

Copying constructor.

Note
This also supports direct non-checked implicit conversion between Checked types that differ only in their non-type NoExcept template paramaeter value.
Postcondition
The constructed object compares equally to other .

Member Function Documentation

◆ get()

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
constexpr underlying_type playrho::detail::Checked< ValueType, Checker, NoExcept >::get ( ) const
inlineconstexprnoexcept

Explicitly gets the underlying value.

Note
This can also be cast to the underlying value.

◆ operator U() [1/2]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class U , std::enable_if_t< std::conjunction_v< std::negation< IsChecked< U >>, std::is_constructible< U, ValueType >, std::negation< is_narrowing_conversion< ValueType, U >> >, bool > = true>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::operator U ( ) const
inlineconstexprnoexcept

Implicitly gets the underlying value via a cast or implicit conversion.

See also
get.

◆ operator U() [2/2]

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class U , std::enable_if_t< std::conjunction_v< std::negation< IsChecked< U >>, std::is_constructible< U, ValueType >, is_narrowing_conversion< ValueType, U > >, bool > = false>
constexpr playrho::detail::Checked< ValueType, Checker, NoExcept >::operator U ( ) const
inlineexplicitconstexprnoexcept

Explicitly gets the underlying value via a cast or implicit conversion.

See also
get.

◆ operator*()

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class U = ValueType>
constexpr std::enable_if_t<std::is_pointer_v<U>, remove_pointer_type>& playrho::detail::Checked< ValueType, Checker, NoExcept >::operator* ( ) const
inlineconstexpr

Indirection operator available for pointer ValueType.

Note
This is only available for pointer ValueTypes.

◆ operator->()

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
template<class U = ValueType>
constexpr std::enable_if_t<std::is_pointer_v<U>, U> playrho::detail::Checked< ValueType, Checker, NoExcept >::operator-> ( ) const
inlineconstexpr

Member-of pointer operator available for pointer ValueType.

Note
This is only available for pointer ValueTypes.

◆ ThrowIfInvalid()

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
static constexpr auto playrho::detail::Checked< ValueType, Checker, NoExcept >::ThrowIfInvalid ( const underlying_type value) -> decltype((void)exception_type(Checker{}(value)), std::declval<void>())
inlinestaticconstexpr

Throws this class's exception type if the given value is invalid.

Exceptions
exception_typeConstructed with the returned error - if the checker returned a non-null explanatory string.
See also
exception_type.

◆ Validate()

template<class ValueType , class Checker = NoOpChecker<ValueType>, bool NoExcept = false>
static constexpr auto playrho::detail::Checked< ValueType, Checker, NoExcept >::Validate ( const underlying_type value) -> decltype(ThrowIfInvalid(value), underlying_type{})
inlinestaticconstexprnoexcept

Validator function.

Validates the given value using the checker_type type and returns the value given if it checks out.

Precondition
value must be valid if NoExcept is true.
Exceptions
exception_typeConstructed with the returned error - if the checker returned a non-null explanatory string - and NoExcept is false.
Returns
Value given.

Referenced by playrho::detail::Checked< ValueType, Checker, NoExcept >::Checked().

Friends And Related Function Documentation

◆ operator!=() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator!= ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) != RhsValueType(rhs))
related

Constrained value inequality operator for value types which support it.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator!=() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator!= ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) != rhs)
related

Constrained value inequality operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator!=() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator!= ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(lhs != ValueType(rhs))
related

Constrained value inequality operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator*() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator* ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) * RhsValueType(rhs))
related

Constrained value multiplication operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator*() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator* ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> std::enable_if_t<!IsMultipliableV<Checked<ValueType, Checker, NoExcept>, Other>, decltype(ValueType()*Other())>
related

Constrained value multiplication operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator*() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator* ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> std::enable_if_t<!IsMultipliableV<Other, Checked<ValueType, Checker, NoExcept>>, decltype(Other()*ValueType())>
related

Constrained value multiplication operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator+() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator+ ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) + RhsValueType(rhs))
related

Constrained value addition operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator+() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator+ ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) + rhs)
related

Constrained value addition operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator+() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator+ ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(lhs + ValueType(rhs))
related

Constrained value addition operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator-() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator- ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) - RhsValueType(rhs))
related

Constrained value subtraction operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator-() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator- ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) - rhs)
related

Constrained value subtraction operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator-() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator- ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(lhs - ValueType(rhs))
related

Constrained value subtraction operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator/() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator/ ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) / RhsValueType(rhs))
related

Constrained value division operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator/() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator/ ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) / rhs)
related

Constrained value division operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator/() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator/ ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(lhs / ValueType(rhs))
related

Constrained value division operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator<() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator< ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) < RhsValueType(rhs))
related

Constrained value less-than operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator<() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator< ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) < ValueType(rhs))
related

Constrained value less-than operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator<() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator< ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(ValueType(lhs) < ValueType(rhs))
related

Constrained value less-than operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator<<()

template<class ValueType , class Checker , bool NoExcept>
auto operator<< ( ::std::ostream &  os,
const Checked< ValueType, Checker, NoExcept > &  value 
) -> decltype(os << ValueType(value))
related

Constrained value stream output operator for value types which support it.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.

◆ operator<=() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator<= ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) <= RhsValueType(rhs))
related

Constrained value less-than or equal-to operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator<=() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator<= ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) <= ValueType(rhs))
related

Constrained value less-than or equal-to operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator<=() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator<= ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(ValueType(lhs) <= ValueType(rhs))
related

Constrained value less-than or equal-to operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator==() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator== ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) == RhsValueType(rhs))
related

Constrained value equality operator for value types which support it.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator==() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator== ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) == rhs)
related

Constrained value equality operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator==() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator== ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(lhs == ValueType(rhs))
related

Constrained value equality operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator>() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator> ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) > RhsValueType(rhs))
related

Constrained value greater-than operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator>() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator> ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) > ValueType(rhs))
related

Constrained value greater-than operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator>() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator> ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(ValueType(lhs) > ValueType(rhs))
related

Constrained value greater-than ooperator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator>=() [1/3]

template<class LhsValueType , class LhsChecker , bool LhsNoExcept, class RhsValueType , class RhsChecker , bool RhsNoExcept>
constexpr auto operator>= ( const Checked< LhsValueType, LhsChecker, LhsNoExcept > &  lhs,
const Checked< RhsValueType, RhsChecker, RhsNoExcept > &  rhs 
) -> decltype(LhsValueType(lhs) >= RhsValueType(rhs))
related

Constrained value greater-than or equal-to operator.

Template Parameters
LhsValueTypeType of the value used by the left hand side checked value.
LhsCheckerType of the checker used by the left hand side checked value.
LhsNoExceptWhether left hand side type terminates or just throws for invalid values.
RhsValueTypeType of the value used by the right hand side checked value.
RhsCheckerType of the checker used by the right hand side checked value.
RhsNoExceptWhether right hand side type terminates or just throws for invalid values.

◆ operator>=() [2/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator>= ( const Checked< ValueType, Checker, NoExcept > &  lhs,
const Other &  rhs 
) -> decltype(ValueType(lhs) >= ValueType(rhs))
related

Constrained value greater-than or equal-to operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

◆ operator>=() [3/3]

template<class ValueType , class Checker , bool NoExcept, class Other >
constexpr auto operator>= ( const Other &  lhs,
const Checked< ValueType, Checker, NoExcept > &  rhs 
) -> decltype(ValueType(lhs) >= ValueType(rhs))
related

Constrained value greater-than or equal-to operator.

Template Parameters
ValueTypeType of the value used by the checked value.
CheckerType of the checker used by the checked value.
NoExceptWhether checked type terminates or just throws for invalid values.
OtherType of the other value that this operation will operator with.

The documentation for this class was generated from the following file: