std::numeric_limits<T>::is_integer
Von de.cppreference.net
static const bool is_integer;
|
(bis C++11) | |
static constexpr bool is_integer;
|
(seit C++11) | |
Der Wert von std::numeric_limits<T>::is_integer ist true für alle ganzzahligen arithmetischen Typen T und false andernfalls. Diese Konstante ist für alle Spezialisierungen von Bedeutung.
Standardspezialisierungen
T
|
Wert von std:: numeric_limits < T > :: is_integer |
| /* non-specialized */ | false |
| bool | true |
| char | true |
| signed char | true |
| unsigned char | true |
| wchar_t | true |
| char8_t (seit C++20) | true |
| char16_t (seit C++11) | true |
| char32_t (seit C++11) | true |
| short | true |
| unsigned short | true |
| int | true |
| unsigned int | true |
| long | true |
| unsigned long | true |
| long long (seit C++11) | true |
| unsigned long long (seit C++11) | true |
| float | false |
| double | false |
| long double | false |
Beispiel
Diesen Code ausführen
#include <cstddef> #include <cstdint> #include <limits> static_assert ( std::numeric_limits<bool>::is_integer && std::numeric_limits<std::size_t>::is_integer && std::numeric_limits<std::int32_t>::is_integer && std::numeric_limits<std::int64_t>::is_integer && std::numeric_limits<decltype(42)>::is_integer && !std::numeric_limits<int*>::is_integer && !std::numeric_limits<float>::is_integer && !std::numeric_limits<double>::is_integer && !std::numeric_limits<long double>::is_integer && !std::numeric_limits<decltype([](){})>::is_integer // P0315R4 ); int main() {}
Siehe auch
|
(C++11)
|
prüft, ob ein Typ ein integraler Typ ist
(Klassen-Template) |
|
[static]
|
identifiziert vorzeichenbehaftete Typen
(öffentliche statische Member-Konstante) |
|
[static]
|
identifiziert exakte Typen
(öffentliche statische Member-Konstante) |
|
[static]
|
identifiziert Typen, die eine endliche Wertemenge repräsentieren
(öffentliche statische Member-Konstante) |