DGtal  1.3.beta
Public Types | Static Public Member Functions | Static Public Attributes | Private Types
DGtal::details::NumberTraitsImplFundamental< T > Struct Template Reference

NumberTraits common part for fundamental integer and floating-point types. More...

#include <DGtal/kernel/NumberTraits.h>

Inheritance diagram for DGtal::details::NumberTraitsImplFundamental< T >:
[legend]

Public Types

using IsBounded = typename BoolToTag< NL::is_bounded >::type
 Is the number bounded. More...
 
using IsUnsigned = typename BoolToTag<!NL::is_signed >::type
 Is the number unsigned. More...
 
using IsSigned = typename BoolToTag< NL::is_signed >::type
 Is the number signed. More...
 
using IsIntegral = typename BoolToTag< NL::is_integer >::type
 Is the number of integral type. More...
 
using IsSpecialized = TagTrue
 Is that a number type with specific traits. More...
 
using ReturnType = T
 Alias to the type that should be used as return type. More...
 
using ParamType = typename boost::call_traits< T >::param_type
 Defines a type that represents the "best" way to pass a parameter of type T to a function. More...
 

Static Public Member Functions

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

Static Public Attributes

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

Private Types

using NL = std::numeric_limits< T >
 Type alias to std::numeric_limits. More...
 

Detailed Description

template<typename T>
struct DGtal::details::NumberTraitsImplFundamental< T >

NumberTraits common part for fundamental integer and floating-point types.

Definition at line 203 of file NumberTraits.h.

Member Typedef Documentation

◆ IsBounded

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::IsBounded = typename BoolToTag<NL::is_bounded>::type

Is the number bounded.

Definition at line 210 of file NumberTraits.h.

◆ IsIntegral

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::IsIntegral = typename BoolToTag<NL::is_integer>::type

Is the number of integral type.

Definition at line 213 of file NumberTraits.h.

◆ IsSigned

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::IsSigned = typename BoolToTag<NL::is_signed>::type

Is the number signed.

Definition at line 212 of file NumberTraits.h.

◆ IsSpecialized

Is that a number type with specific traits.

Definition at line 214 of file NumberTraits.h.

◆ IsUnsigned

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::IsUnsigned = typename BoolToTag<!NL::is_signed>::type

Is the number unsigned.

Definition at line 211 of file NumberTraits.h.

◆ NL

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::NL = std::numeric_limits<T>
private

Type alias to std::numeric_limits.

Definition at line 206 of file NumberTraits.h.

◆ ParamType

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::ParamType = typename boost::call_traits<T>::param_type

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

Definition at line 221 of file NumberTraits.h.

◆ ReturnType

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::ReturnType = T

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

Definition at line 216 of file NumberTraits.h.

Member Function Documentation

◆ castToDouble()

template<typename T >
static constexpr double DGtal::details::NumberTraitsImplFundamental< T >::castToDouble ( const T &  aT)
inlinestaticconstexprnoexcept

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

Definition at line 299 of file NumberTraits.h.

300  {
301  return static_cast<double>(aT);
302  }

◆ castToInt64_t()

template<typename T >
static constexpr DGtal::int64_t DGtal::details::NumberTraitsImplFundamental< T >::castToInt64_t ( const T &  aT)
inlinestaticconstexprnoexcept

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

Definition at line 289 of file NumberTraits.h.

290  {
291  return static_cast<DGtal::int64_t>(aT);
292  }

◆ digits()

template<typename T >
static constexpr unsigned int DGtal::details::NumberTraitsImplFundamental< T >::digits ( )
inlinestaticconstexprnoexcept

Return the number of significant binary digits for this type of number.

Definition at line 259 of file NumberTraits.h.

260  {
261  return static_cast<unsigned int>(NL::digits);
262  }

◆ even()

template<typename T >
static constexpr bool DGtal::details::NumberTraitsImplFundamental< T >::even ( ParamType  aT)
inlinestaticconstexprnoexcept

Check the parity of a number.

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

Definition at line 310 of file NumberTraits.h.

311  {
312  return ( aT & ONE ) == ZERO;
313  }

References DGtal::details::NumberTraitsImplFundamental< T >::ONE, and DGtal::details::NumberTraitsImplFundamental< T >::ZERO.

◆ isBounded()

template<typename T >
static constexpr BoundEnum DGtal::details::NumberTraitsImplFundamental< T >::isBounded ( )
inlinestaticconstexprnoexcept

Return the bounding type of the number.

Returns
BOUNDED, UNBOUNDED, or BOUND_UNKNOWN.

Definition at line 269 of file NumberTraits.h.

270  {
271  return NL::is_bounded ? BOUNDED : UNBOUNDED;
272  }

References DGtal::BOUNDED, and DGtal::UNBOUNDED.

◆ isSigned()

template<typename T >
static constexpr SignEnum DGtal::details::NumberTraitsImplFundamental< T >::isSigned ( )
inlinestaticconstexprnoexcept

Return the sign type of the number.

Returns
SIGNED, UNSIGNED or SIGN_UNKNOWN.

Definition at line 279 of file NumberTraits.h.

280  {
281  return NL::is_signed ? SIGNED : UNSIGNED;
282  }

References DGtal::SIGNED, and DGtal::UNSIGNED.

◆ max()

template<typename T >
static constexpr ReturnType DGtal::details::NumberTraitsImplFundamental< T >::max ( )
inlinestaticconstexprnoexcept

Return the maximum possible value for this type of number.

Definition at line 252 of file NumberTraits.h.

253  {
254  return NL::max();
255  }

References max().

◆ min()

template<typename T >
static constexpr ReturnType DGtal::details::NumberTraitsImplFundamental< T >::min ( )
inlinestaticconstexprnoexcept

Return the minimum possible value for this type of number.

Definition at line 245 of file NumberTraits.h.

246  {
247  return NL::min();
248  }

◆ odd()

template<typename T >
static constexpr bool DGtal::details::NumberTraitsImplFundamental< T >::odd ( ParamType  aT)
inlinestaticconstexprnoexcept

Check the parity of a number.

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

Definition at line 321 of file NumberTraits.h.

322  {
323  return ( aT & ONE ) != ZERO;
324  }

References DGtal::details::NumberTraitsImplFundamental< T >::ONE, and DGtal::details::NumberTraitsImplFundamental< T >::ZERO.

◆ one()

template<typename T >
static constexpr ReturnType DGtal::details::NumberTraitsImplFundamental< T >::one ( )
inlinestaticconstexprnoexcept

Return the one of this integer.

Definition at line 238 of file NumberTraits.h.

239  {
240  return ONE;
241  }

References DGtal::details::NumberTraitsImplFundamental< T >::ONE.

◆ zero()

template<typename T >
static constexpr ReturnType DGtal::details::NumberTraitsImplFundamental< T >::zero ( )
inlinestaticconstexprnoexcept

Return the zero of this integer.

Definition at line 231 of file NumberTraits.h.

232  {
233  return ZERO;
234  }

References DGtal::details::NumberTraitsImplFundamental< T >::ZERO.

Field Documentation

◆ ONE

template<typename T >
constexpr T DGtal::details::NumberTraitsImplFundamental< T >::ONE = T(1)
staticconstexpr

◆ ZERO

template<typename T >
constexpr T DGtal::details::NumberTraitsImplFundamental< T >::ZERO = T(0)
staticconstexpr

The documentation for this struct was generated from the following file:
max
int max(int a, int b)
Definition: testArithmeticalDSS.cpp:1108
DGtal::details::NumberTraitsImplFundamental::ZERO
static constexpr T ZERO
Constant Zero.
Definition: NumberTraits.h:224
DGtal::BOUNDED
@ BOUNDED
Definition: NumberTraits.h:54
DGtal::UNBOUNDED
@ UNBOUNDED
Definition: NumberTraits.h:54
DGtal::UNSIGNED
@ UNSIGNED
Definition: NumberTraits.h:57
DGtal::details::NumberTraitsImplFundamental::ONE
static constexpr T ONE
Constant One.
Definition: NumberTraits.h:227
DGtal::int64_t
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
DGtal::SIGNED
@ SIGNED
Definition: NumberTraits.h:57