std:: unsigned_integral
From cppreference.net
|
Défini dans l'en-tête
<concepts>
|
||
|
template
<
class
T
>
concept unsigned_integral = std:: integral < T > && ! std:: signed_integral < T > ; |
(depuis C++20) | |
Le concept
unsigned_integral<T>
est satisfait si et seulement si
T
est un type intégral et que
std::
is_signed_v
<
T
>
est
false
.
Table des matières |
Notes
unsigned_integral<T>
peut être satisfait par un type qui n'est pas un
type entier non signé
, par exemple,
bool
.
Exemple
Exécuter ce code
#include <concepts> #include <iostream> #include <string_view> void test(std::signed_integral auto x, std::string_view text = "") { std::cout << text << " (" + (text == "") << x << ") is a signed integral\n"; } void test(std::unsigned_integral auto x, std::string_view text = "") { std::cout << text << " (" + (text == "") << x << ") is an unsigned integral\n"; } void test(auto x, std::string_view text = "") { std::cout << text << " (" + (text == "") << x << ") is non-integral\n"; } int main() { test(42); // signé test(0xFULL, "0xFULL"); // non signé test('A'); // dépendant de la plateforme test(true, "true"); // non signé test(4e-2, "4e-2"); // non intégral (hex-float) test("∫∫"); // non intégral }
Sortie possible :
(42) is a signed integral 0xFULL (15) is an unsigned integral (A) is a signed integral true (1) is an unsigned integral 4e-2 (0.04) is non-integral (∫∫) is non-integral
Références
- Norme C++23 (ISO/IEC 14882:2024) :
-
- 18.4.7 Concepts arithmétiques [concepts.arithmetic]
- Norme C++20 (ISO/CEI 14882:2020) :
-
- 18.4.7 Concepts arithmétiques [concepts.arithmetic]
Voir aussi
|
(C++11)
|
vérifie si un type est un type entier
(modèle de classe) |
|
(C++11)
|
vérifie si un type est un type arithmétique signé
(modèle de classe) |