Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::Quantity< T, D > Class Template Reference

CRTP class that wraps T to ensure it's value stays within a certain range. More...

#include <quantity.h>

Public Types

using ValueType = T

Public Member Functions

constexpr Quantity () noexcept
 Default-constructs the internal value. Lower bound is used if not within range.
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr Quantity (U value)
 Sets the value. Throws std::exception if out of range.
 ~Quantity ()=default
constexpr T get () const noexcept
 The stored value.
constexpr operator T () const noexcept
 The stored value.
constexpr bool isValid () const noexcept
 The validity of data.
constexpr operator bool () const noexcept
 The validity of data.
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr Quantityoperator= (U other)
 Sets the value. Throws std::exception if out of range.
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr void set (U other)
 Sets the value. Throws std::exception if out of range.
constexpr void setValid (bool valid)
 Sets the validity of data.
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr bool operator== (const U &other) const
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr bool operator!= (const U &other) const
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr bool operator< (const U &other) const
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr bool operator<= (const U &other) const
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr bool operator> (const U &other) const
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr bool operator>= (const U &other) const

Detailed Description

template<typename T, typename D>
class sen::Quantity< T, D >

CRTP class that wraps T to ensure it's value stays within a certain range.

Member Typedef Documentation

◆ ValueType

template<typename T, typename D>
using sen::Quantity< T, D >::ValueType = T

Constructor & Destructor Documentation

◆ Quantity() [1/2]

template<typename T, typename D>
sen::Quantity< T, D >::Quantity ( )
constexprnoexcept

Default-constructs the internal value. Lower bound is used if not within range.

◆ Quantity() [2/2]

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
sen::Quantity< T, D >::Quantity ( U value)
inlineconstexpr

Sets the value. Throws std::exception if out of range.

◆ ~Quantity()

template<typename T, typename D>
sen::Quantity< T, D >::~Quantity ( )
default

Member Function Documentation

◆ get()

template<typename T, typename D>
T sen::Quantity< T, D >::get ( ) const
inlinenodiscardconstexprnoexcept

The stored value.

◆ operator T()

template<typename T, typename D>
sen::Quantity< T, D >::operator T ( ) const
inlineconstexprnoexcept

The stored value.

◆ isValid()

template<typename T, typename D>
bool sen::Quantity< T, D >::isValid ( ) const
inlinenodiscardconstexprnoexcept

The validity of data.

◆ operator bool()

template<typename T, typename D>
sen::Quantity< T, D >::operator bool ( ) const
inlineexplicitconstexprnoexcept

The validity of data.

◆ operator=()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
Quantity & sen::Quantity< T, D >::operator= ( U other)
inlineconstexpr

Sets the value. Throws std::exception if out of range.

◆ set()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
void sen::Quantity< T, D >::set ( U other)
inlineconstexpr

Sets the value. Throws std::exception if out of range.

◆ setValid()

template<typename T, typename D>
void sen::Quantity< T, D >::setValid ( bool valid)
inlineconstexpr

Sets the validity of data.

◆ operator==()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
bool sen::Quantity< T, D >::operator== ( const U & other) const
inlineconstexpr

◆ operator!=()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
bool sen::Quantity< T, D >::operator!= ( const U & other) const
inlineconstexpr

◆ operator<()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
bool sen::Quantity< T, D >::operator< ( const U & other) const
inlineconstexpr

◆ operator<=()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
bool sen::Quantity< T, D >::operator<= ( const U & other) const
inlineconstexpr

◆ operator>()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
bool sen::Quantity< T, D >::operator> ( const U & other) const
inlineconstexpr

◆ operator>=()

template<typename T, typename D>
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
bool sen::Quantity< T, D >::operator>= ( const U & other) const
inlineconstexpr

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