Type Traits

Header aarith/core/traits.hpp

Unfortunately, adding specializations for type traits such as is_integral is undefined.

Hence we copy the relevant traits into the aarith namespace.

namespace aarith

Variables

template<class Type>
constexpr bool is_word_array_v = is_word_array<Type>::value

Test for a type being an word array.

Helper for the is_word_array type trait

Template Parameters

Type – Type to check for being an aarith word array

template<class Type>
constexpr bool is_integral_v = is_integral<Type>::value

Test for a type being an aarith integer.

Helper for the is_integral type trait

Template Parameters

Type – The type to check

template<class Type>
constexpr bool is_unsigned_v = is_unsigned<Type>::value

Test for an aarith type to be unsigned.

Template Parameters

Type – The type to check

template<class Type>
constexpr bool is_signed_v = is_signed<Type>::value

Test for an aarith type to be signed.

Template Parameters

Type – The type to check

template<class T>
constexpr bool is_arithmetic_v = is_arithmetic<T>::value

Test for an aarith type being an arithmetic type.

Template Parameters

T – The type to check

template<class Type>
constexpr bool is_float_v = is_float<Type>::value

Tests if a type is an aarith floating_point.

Helper for the is_float type trait

Template Parameters

Type – The type to check for being an aarith floating_point

template<typename A, typename B>
constexpr bool same_word_type = std::is_same_v<typename A::word_type, typename B::word_type>

Type trait to check if two types use the same word type to store the data.

Template Parameters
  • A – First type

  • B – Second type

template<typename A, typename B>
constexpr bool same_signedness = (is_unsigned_v<A> == is_unsigned_v<B>)

Type trait to check if two types have the same ‘signedness’.

It returns true if and only if both types are signed or unsigned

Template Parameters
  • A – First type

  • B – Second type

template<typename T>
constexpr bool is_unsigned_int = std::is_same_v<T, std::size_t> || std::is_same_v<T, uint64_t> || std::is_same_v<T, uint32_t> || std::is_same_v<T, uint16_t> || std::is_same_v<T, uint8_t>

Type trait to check a type for being an unsigned integer.

It seems that the type traits of C++ have no reasonable concept of “unsigned integer” so we have to add this ourselves.

Template Parameters

T – The type to check for “unsigned int’nes”

template<class T>
struct is_arithmetic
#include <traits.hpp>

Type trait for an aarith type being an arithmetic type.

Template Parameters

T – The type to check

Public Static Attributes

static constexpr bool value = false

By default, no type is an arithmetic type

template<class Type>
class is_float
#include <traits.hpp>

Type trait to check if a type is an aarith floating_point number.

Note

This does not return true for the native data types such as float or double!

Template Parameters

Type – The type to check

Public Static Attributes

static constexpr bool value = false

By default, a type is not of type aarith floating_point

template<class Type>
class is_integral
#include <traits.hpp>

Type trait to check if a type is an aarith integer.

Template Parameters

Type – The Type to check

Public Static Attributes

static constexpr bool value = false

By default, mo type is an aarith integer

template<class Type>
class is_signed
#include <traits.hpp>

Type trait to check if a type is a signed aarith type.

Template Parameters

Type – The type to check

Public Static Attributes

static constexpr bool value = false

By default, no type is an signed aarith type

template<class Type>
class is_unsigned
#include <traits.hpp>

Type trait to check if a type is an unsigned aarith type.

Template Parameters

Type – The type to check

Public Static Attributes

static constexpr bool value = false

By default, no type is an unsigned type

template<class Type>
class is_word_array
#include <traits.hpp>

Type trait to check if a type is a word array.

See also

word_array

Template Parameters

Type – The type to check

Public Static Attributes

static constexpr bool value = false

By default, no type is an aarith word array