std::unsigned_integral(3)
okay so this is the std::unsigned_integral(3) page from the C++ Standard Libary manual, and it's lowkey giving βis this type unsigned-integral?β main character energy πβ¨
β¨ NAME β¨
std::unsigned_integral β thatβs the whole name, bestie: std::unsigned_integral. No extra subtitle, no side quest. π
πΈ Synopsis πΈ
Defined in header <concepts>
template< class T >
concept unsigned_integral = std::integral<T> &&
(since C++20)
!std::signed_integral<T>;
The concept unsigned_integral<T> is satisfied if and only if T is an integral type and std::is_signed_v<T> is false. no cap, that's the whole vibe check π«Ά
π Notes π
Bestie, listen: unsigned_integral<T> may be satisfied by a type that is not an unsigned integer type β for example, bool. yes, bool is out here sneaking into the unsigned-integral party ππ
π Example π
// Run this 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); // signed
test(0xFULL, "0xFULL"); // unsigned
test('A'); // platform-dependent
test(true, "true"); // unsigned
test(4e-2, "4e-2"); // non-integral (hex-float)
test("β«β«"); // non-integral
}
β¨ Possible output β¨
(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
π See also π
is_integralβ checks if a type is an integral type (C++11) (class template)is_signedβ checks if a type is a signed arithmetic type (C++11) (class template)
source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::unsigned_integral(3) β mwah, go check your integral vibes, bestie ππ¦π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms