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.
|
expression |
value |
|---|---|
|
|
any arithmetic type |
|
|
An |
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 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
![]() |
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 |