PrevUpHomeNext

Type trait arithmetic_rank

In C++, the term arithmetic type refers to a fundamental type which is either integral or floating point.

As part of the definition of safely_constructible, strict_variant makes a finer classification of these types, and assigns a portable conversion rank to each such type.

The type trait arithmetic_rank computes the rank of a given arithmetic type.

Valid Expressions

expression

value

T

any arithmetic type

strict_variant::mpl::arithmetic_rank<T>::value

An int representing the conversion rank of T, within its category

Definition

Note that for strict_variant, comparing these numbers is only meaningful within an arithmetic category.

The purpose of these numbers is, if C++ permits A to be narrower than B, and A and B are in the same category, then A has a lower rank than B.

Fundmental Type

arithmetic rank

(unsigned) short

0

(unsigned) int

1

(unsigned) long

2

(unsigned) long long

3

signed char

0

char

0

unsigned char

0

char16_t

1

char32_t

2

float

0

double

1

long double

2

bool

0

wchar_t

0

[Note] Note

You are free to specialize this trait to support other arithmetic types, such as implementation-specific extended integers.

If you have e.g. an 128 bit integer type which you want to support, most likely you want to define its rank to be 4 by specializing this trait.


PrevUpHomeNext