DGtal 1.3.0
Loading...
Searching...
No Matches
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 >:
DGtal::NumberTraitsImpl< T, typename std::enable_if< std::is_floating_point< T >::value >::type > DGtal::NumberTraitsImpl< T, typename std::enable_if< std::is_integral< T >::value >::type >

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 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 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 213 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 220 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 223 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 222 of file NumberTraits.h.

◆ IsSpecialized

template<typename T >
using DGtal::details::NumberTraitsImplFundamental< T >::IsSpecialized = TagTrue

Is that a number type with specific traits.

Definition at line 224 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 221 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 216 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 231 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 226 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 319 of file NumberTraits.h.

320 {
321 return static_cast<double>(aT);
322 }

◆ 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 299 of file NumberTraits.h.

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

◆ castToUInt64_t()

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

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

Definition at line 309 of file NumberTraits.h.

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

◆ 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 269 of file NumberTraits.h.

270 {
271 return static_cast<unsigned int>(NL::digits);
272 }

◆ 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 330 of file NumberTraits.h.

331 {
332 return ( aT & ONE ) == ZERO;
333 }
static constexpr T ZERO
Constant Zero.
Definition: NumberTraits.h:234
static constexpr T ONE
Constant One.
Definition: NumberTraits.h:237

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 279 of file NumberTraits.h.

280 {
281 return NL::is_bounded ? BOUNDED : UNBOUNDED;
282 }
@ UNBOUNDED
Definition: NumberTraits.h:54
@ BOUNDED
Definition: NumberTraits.h:54

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 289 of file NumberTraits.h.

290 {
291 return NL::is_signed ? SIGNED : UNSIGNED;
292 }
@ UNSIGNED
Definition: NumberTraits.h:57
@ SIGNED
Definition: NumberTraits.h:57

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 262 of file NumberTraits.h.

263 {
264 return NL::max();
265 }

◆ 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 255 of file NumberTraits.h.

256 {
257 return NL::min();
258 }

◆ 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 341 of file NumberTraits.h.

342 {
343 return ( aT & ONE ) != ZERO;
344 }

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 248 of file NumberTraits.h.

249 {
250 return ONE;
251 }

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 241 of file NumberTraits.h.

242 {
243 return ZERO;
244 }

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: