The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::bounded_int< T, min_bound, max_bound > Class Template Reference

Bounded integer type with range-checking. More...

#include <Utils.hpp>

Public Member Functions

 bounded_int (const bounded_int &)=default
 
 bounded_int (bounded_int &&)=default
 
template<typename ArgT = T>
 bounded_int (ArgT, typename std::enable_if< std::is_integral< ArgT >::value==false &&std::is_convertible< ArgT, T >::value==false >::type *=0)
 
template<typename ArgT = T>
 bounded_int (ArgT val, typename std::enable_if< std::is_integral< ArgT >::value==false &&std::is_convertible< ArgT, T >::value==true >::type *=0)
 
template<typename ArgT = T>
 bounded_int (ArgT val, typename std::enable_if< std::is_integral< ArgT >::value &&std::is_signed< ArgT >::value!=std::is_signed< T >::value >::type *=0)
 
template<typename ArgT = T>
 bounded_int (ArgT val, typename std::enable_if< std::is_integral< ArgT >::value &&(sizeof(ArgT)<=sizeof(T)) &&std::is_signed< ArgT >::value==std::is_signed< T >::value >::type *=0)
 
template<typename ArgT = T>
 bounded_int (ArgT val, typename std::enable_if< std::is_integral< ArgT >::value &&(sizeof(ArgT) > sizeof(T)) &&std::is_signed< ArgT >::value==std::is_signed< T >::value >::type *=0)
 
template<typename ArgT >
void rangeCheck_ (ArgT val)
 
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::min()!=min_bound, void >::type lowerRangeCheck_ (ArgT val) const
 
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::min()==min_bound, void >::type lowerRangeCheck_ (ArgT val) const
 
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::max()!=max_bound, void >::type upperRangeCheck_ (ArgT val) const
 
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::max()==max_bound, void >::type upperRangeCheck_ (ArgT val) const
 
 operator T () const
 Cast to the held type.
 
bool operator== (const bounded_int &)=delete
 Deleted comaprison with bounded in (until implemented fully)
 
bool operator= (const bounded_int &)=delete
 Deleted comaprison with bounded in (until implemented fully)
 

Detailed Description

template<typename T, T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
class sparta::bounded_int< T, min_bound, max_bound >

Bounded integer type with range-checking.

Template Parameters
Ttype to hold
min_boundMinimum bound (inclusive)
max_boundMaximum bound (inclusive)

Definition at line 583 of file Utils.hpp.

Constructor & Destructor Documentation

◆ bounded_int() [1/5]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
sparta::bounded_int< T, min_bound, max_bound >::bounded_int ( ArgT  ,
typename std::enable_if< std::is_integral< ArgT >::value==false &&std::is_convertible< ArgT, T >::value==false >::type *  = 0 
)
inline

Definition at line 593 of file Utils.hpp.

◆ bounded_int() [2/5]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
sparta::bounded_int< T, min_bound, max_bound >::bounded_int ( ArgT  val,
typename std::enable_if< std::is_integral< ArgT >::value==false &&std::is_convertible< ArgT, T >::value==true >::type *  = 0 
)
inline

Definition at line 602 of file Utils.hpp.

◆ bounded_int() [3/5]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
sparta::bounded_int< T, min_bound, max_bound >::bounded_int ( ArgT  val,
typename std::enable_if< std::is_integral< ArgT >::value &&std::is_signed< ArgT >::value!=std::is_signed< T >::value >::type *  = 0 
)
inline

Definition at line 611 of file Utils.hpp.

◆ bounded_int() [4/5]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
sparta::bounded_int< T, min_bound, max_bound >::bounded_int ( ArgT  val,
typename std::enable_if< std::is_integral< ArgT >::value &&(sizeof(ArgT)<=sizeof(T)) &&std::is_signed< ArgT >::value==std::is_signed< T >::value >::type *  = 0 
)
inline

Definition at line 620 of file Utils.hpp.

◆ bounded_int() [5/5]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
sparta::bounded_int< T, min_bound, max_bound >::bounded_int ( ArgT  val,
typename std::enable_if< std::is_integral< ArgT >::value &&(sizeof(ArgT) > sizeof(T)) &&std::is_signed< ArgT >::value==std::is_signed< T >::value >::type *  = 0 
)
inline

Definition at line 635 of file Utils.hpp.

Member Function Documentation

◆ lowerRangeCheck_() [1/2]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::min()!=min_bound, void >::type sparta::bounded_int< T, min_bound, max_bound >::lowerRangeCheck_ ( ArgT  val) const
inline

Definition at line 652 of file Utils.hpp.

◆ lowerRangeCheck_() [2/2]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::min()==min_bound, void >::type sparta::bounded_int< T, min_bound, max_bound >::lowerRangeCheck_ ( ArgT  val) const
inline

Definition at line 660 of file Utils.hpp.

◆ operator T()

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
sparta::bounded_int< T, min_bound, max_bound >::operator T ( ) const
inline

Cast to the held type.

Todo:
Add static methods to convert a value using additional bounds. A new bounded value can be constructed to achieve this as well.
Note
May be made explicit. Methods for comparison and truncation would be made available.

Definition at line 692 of file Utils.hpp.

◆ rangeCheck_()

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT >
void sparta::bounded_int< T, min_bound, max_bound >::rangeCheck_ ( ArgT  val)
inline

Definition at line 645 of file Utils.hpp.

◆ upperRangeCheck_() [1/2]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::max()!=max_bound, void >::type sparta::bounded_int< T, min_bound, max_bound >::upperRangeCheck_ ( ArgT  val) const
inline

Definition at line 666 of file Utils.hpp.

◆ upperRangeCheck_() [2/2]

template<typename T , T min_bound = std::numeric_limits<T>::min(), T max_bound = std::numeric_limits<T>::max()>
template<typename ArgT = T>
std::enable_if< std::numeric_limits< ArgT >::max()==max_bound, void >::type sparta::bounded_int< T, min_bound, max_bound >::upperRangeCheck_ ( ArgT  val) const
inline

Definition at line 674 of file Utils.hpp.


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