std:: unsigned_integral
From cppreference.net
|
Definido en el encabezado
<concepts>
|
||
|
template
<
class
T
>
concept unsigned_integral = std:: integral < T > && ! std:: signed_integral < T > ; |
(desde C++20) | |
El concepto
unsigned_integral<T>
se satisface si y solo si
T
es un tipo integral y
std::
is_signed_v
<
T
>
es
false
.
Contenidos |
Notas
unsigned_integral<T>
puede ser satisfecho por un tipo que no es un
tipo entero sin signo
, por ejemplo,
bool
.
Ejemplo
Ejecutar este código
#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); // con signo test(0xFULL, "0xFULL"); // sin signo test('A'); // dependiente de la plataforma test(true, "true"); // sin signo test(4e-2, "4e-2"); // no entero (hex-float) test("∫∫"); // no entero }
Salida posible:
(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
Referencias
- Estándar C++23 (ISO/IEC 14882:2024):
-
- 18.4.7 Conceptos aritméticos [concepts.arithmetic]
- Estándar C++20 (ISO/IEC 14882:2020):
-
- 18.4.7 Conceptos aritméticos [concepts.arithmetic]
Véase también
|
(C++11)
|
comprueba si un tipo es un tipo integral
(plantilla de clase) |
|
(C++11)
|
comprueba si un tipo es un tipo aritmético con signo
(plantilla de clase) |