DGtal  1.5.beta
DGtal::NumberTraitsImpl< T, Enable > Struct Template Reference

Aim: The traits class for all models of Cinteger (implementation) More...

#include <DGtal/kernel/NumberTraits.h>

Inheritance diagram for DGtal::NumberTraitsImpl< T, Enable >:
[legend]

Public Types

typedef TagUnknown IsBounded
 Is the number bounded. More...
 
typedef TagUnknown IsUnsigned
 Is the number unsigned. More...
 
typedef TagUnknown IsSigned
 Is the number signed. More...
 
typedef TagUnknown IsIntegral
 Is the number of integral type. More...
 
typedef TagFalse IsSpecialized
 Is that a number type with specific traits. More...
 
typedef T SignedVersion
 Alias to the signed version of the number type. More...
 
typedef T UnsignedVersion
 Alias to the unsigned version of the number type. More...
 
typedef T ReturnType
 Alias to the type that should be used as return type. More...
 
typedef boost::call_traits< T >::param_type ParamType
 Defines a type that represents the "best" way to pass a parameter of type T to a function. More...
 

Static Public Member Functions

static ReturnType zero ()
 Return the zero of this integer. More...
 
static ReturnType one ()
 Return the one of this integer. More...
 
static ReturnType min ()
 Return the minimum possible value for this type of integer or ONE if not bounded or unknown. More...
 
static ReturnType max ()
 Return the maximum possible value for this type of integer or ZERO if not bounded or unknown. More...
 
static unsigned int digits ()
 Return the number of significant binary digits for this integer type, or 0 if unbounded or unknown. More...
 
static BoundEnum isBounded ()
 Return the bounding type of the number. More...
 
static SignEnum isSigned ()
 Return the sign type of the number. More...
 
static DGtal::int64_t castToInt64_t (const T &aT)
 Cast method to DGtal::int64_t (for I/O or board export uses only). More...
 
static constexpr DGtal::uint64_t castToUInt64_t (const T &aT) noexcept
 Cast method to DGtal::uint64_t (for I/O or board export uses only). More...
 
static double castToDouble (const T &aT)
 Cast method to double (for I/O or board export uses only). More...
 
static bool even (ParamType aT)
 Check the parity of a number. More...
 
static bool odd (ParamType aT)
 Check the parity of a number. More...
 

Static Public Attributes

static const T ZERO = T(0)
 Constant Zero. More...
 
static const T ONE = T(1)
 Constant One. More...
 

Detailed Description

template<typename T, typename Enable = void>
struct DGtal::NumberTraitsImpl< T, Enable >

Aim: The traits class for all models of Cinteger (implementation)

Description of template class 'NumberTraitsImpl'

Since CInteger describes the concept Integer, this class is used by models of CIinteger to specialize some definitions related to Integer. For instance it defines whether a given Integer is signed or not and what is signed/unsigned version.

This is the fallback declaration for unknown types (IsSpecialized points to TagFalse).

Template Parameters
TNumber type.
EnableInternal template parameter used for SFINAE.
See also
NumberTraits

Definition at line 81 of file NumberTraits.h.

Member Typedef Documentation

◆ IsBounded

template<typename T , typename Enable = void>
typedef TagUnknown DGtal::NumberTraitsImpl< T, Enable >::IsBounded

Is the number bounded.

Definition at line 84 of file NumberTraits.h.

◆ IsIntegral

template<typename T , typename Enable = void>
typedef TagUnknown DGtal::NumberTraitsImpl< T, Enable >::IsIntegral

Is the number of integral type.

Definition at line 87 of file NumberTraits.h.

◆ IsSigned

template<typename T , typename Enable = void>
typedef TagUnknown DGtal::NumberTraitsImpl< T, Enable >::IsSigned

Is the number signed.

Definition at line 86 of file NumberTraits.h.

◆ IsSpecialized

template<typename T , typename Enable = void>
typedef TagFalse DGtal::NumberTraitsImpl< T, Enable >::IsSpecialized

Is that a number type with specific traits.

Definition at line 88 of file NumberTraits.h.

◆ IsUnsigned

template<typename T , typename Enable = void>
typedef TagUnknown DGtal::NumberTraitsImpl< T, Enable >::IsUnsigned

Is the number unsigned.

Definition at line 85 of file NumberTraits.h.

◆ ParamType

template<typename T , typename Enable = void>
typedef boost::call_traits<T>::param_type DGtal::NumberTraitsImpl< T, Enable >::ParamType

Defines a type that represents the "best" way to pass a parameter of type T to a function.

Definition at line 96 of file NumberTraits.h.

◆ ReturnType

template<typename T , typename Enable = void>
typedef T DGtal::NumberTraitsImpl< T, Enable >::ReturnType

Alias to the type that should be used as return type.

Definition at line 91 of file NumberTraits.h.

◆ SignedVersion

template<typename T , typename Enable = void>
typedef T DGtal::NumberTraitsImpl< T, Enable >::SignedVersion

Alias to the signed version of the number type.

Definition at line 89 of file NumberTraits.h.

◆ UnsignedVersion

template<typename T , typename Enable = void>
typedef T DGtal::NumberTraitsImpl< T, Enable >::UnsignedVersion

Alias to the unsigned version of the number type.

Definition at line 90 of file NumberTraits.h.

Member Function Documentation

◆ castToDouble()

template<typename T , typename Enable = void>
static double DGtal::NumberTraitsImpl< T, Enable >::castToDouble ( const T &  aT)
inlinestatic

Cast method to double (for I/O or board export uses only).

Definition at line 164 of file NumberTraits.h.

165  {
166  return static_cast<double>(aT);
167  }

◆ castToInt64_t()

template<typename T , typename Enable = void>
static DGtal::int64_t DGtal::NumberTraitsImpl< T, Enable >::castToInt64_t ( const T &  aT)
inlinestatic

Cast method to DGtal::int64_t (for I/O or board export uses only).

Definition at line 145 of file NumberTraits.h.

146  {
147  return static_cast<DGtal::int64_t>(aT);
148  }
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74

◆ castToUInt64_t()

template<typename T , typename Enable = void>
static constexpr DGtal::uint64_t DGtal::NumberTraitsImpl< T, Enable >::castToUInt64_t ( const T &  aT)
inlinestaticconstexprnoexcept

Cast method to DGtal::uint64_t (for I/O or board export uses only).

Definition at line 155 of file NumberTraits.h.

156  {
157  return static_cast<DGtal::uint64_t>(aT);
158  }
boost::uint64_t uint64_t
unsigned 64-bit integer.
Definition: BasicTypes.h:65

◆ digits()

template<typename T , typename Enable = void>
static unsigned int DGtal::NumberTraitsImpl< T, Enable >::digits ( )
static

Return the number of significant binary digits for this integer type, or 0 if unbounded or unknown.

◆ even()

template<typename T , typename Enable = void>
static bool DGtal::NumberTraitsImpl< T, Enable >::even ( ParamType  aT)
inlinestatic

Check the parity of a number.

Parameters
aTany number.
Returns
'true' iff the number is even.

Definition at line 173 of file NumberTraits.h.

174  {
175  return ( aT & ONE ) == ZERO;
176  }
static const T ONE
Constant One.
Definition: NumberTraits.h:103
static const T ZERO
Constant Zero.
Definition: NumberTraits.h:100

References DGtal::NumberTraitsImpl< T, Enable >::ONE, and DGtal::NumberTraitsImpl< T, Enable >::ZERO.

◆ isBounded()

template<typename T , typename Enable = void>
static BoundEnum DGtal::NumberTraitsImpl< T, Enable >::isBounded ( )
static

Return the bounding type of the number.

Returns
BOUNDED, UNBOUNDED, or BOUND_UNKNOWN.

◆ isSigned()

template<typename T , typename Enable = void>
static SignEnum DGtal::NumberTraitsImpl< T, Enable >::isSigned ( )
static

Return the sign type of the number.

Returns
SIGNED, UNSIGNED or SIGN_UNKNOWN.

◆ max()

template<typename T , typename Enable = void>
static ReturnType DGtal::NumberTraitsImpl< T, Enable >::max ( )
static

Return the maximum possible value for this type of integer or ZERO if not bounded or unknown.

◆ min()

template<typename T , typename Enable = void>
static ReturnType DGtal::NumberTraitsImpl< T, Enable >::min ( )
static

Return the minimum possible value for this type of integer or ONE if not bounded or unknown.

◆ odd()

template<typename T , typename Enable = void>
static bool DGtal::NumberTraitsImpl< T, Enable >::odd ( ParamType  aT)
inlinestatic

Check the parity of a number.

Parameters
aTany number.
Returns
'true' iff the number is odd.

Definition at line 183 of file NumberTraits.h.

184  {
185  return ( aT & ONE ) != ZERO;
186  }

References DGtal::NumberTraitsImpl< T, Enable >::ONE, and DGtal::NumberTraitsImpl< T, Enable >::ZERO.

◆ one()

template<typename T , typename Enable = void>
static ReturnType DGtal::NumberTraitsImpl< T, Enable >::one ( )
static

Return the one of this integer.

◆ zero()

template<typename T , typename Enable = void>
static ReturnType DGtal::NumberTraitsImpl< T, Enable >::zero ( )
static

Return the zero of this integer.

Field Documentation

◆ ONE

template<typename T , typename Enable >
const T DGtal::NumberTraitsImpl< T, Enable >::ONE = T(1)
static

◆ ZERO


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