DGtal 1.4.0
Loading...
Searching...
No Matches
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.
 
using IsUnsigned = typename BoolToTag<!NL::is_signed>::type
 Is the number unsigned.
 
using IsSigned = typename BoolToTag<NL::is_signed>::type
 Is the number signed.
 
using IsIntegral = typename BoolToTag<NL::is_integer>::type
 Is the number of integral type.
 
using IsSpecialized = TagTrue
 Is that a number type with specific traits.
 
using ReturnType = T
 Alias to the type that should be used as return type.
 
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.
 

Static Public Member Functions

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

Static Public Attributes

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

Private Types

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

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.
static constexpr T ONE
Constant One.

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

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 }

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

◆ ZERO


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