std::signed_integral(3)
π NAME π
hey bestie, this is the std::signed_integral(3) page from the C++ Standard Libary β yep, that spelling is in the header and weβre keeping it, periodt. π
std::signed_integral - std::signed_integral β yes, the name is literally the same as the thing, and honestly? iconic minimalism. π
β¨ Synopsis β¨
Defined in header <concepts>.
template< class T >
(since C++20)
concept signed_integral = std::integral<T> && std::is_signed_v<T>;
The concept signed_integral<T> is satisfied if and only if T is an integral type and std::is_signed_v<T> is true. Thatβs the whole vibe check, no cap. β¨
π§ Notes π§
Heads up, bestie: signed_integral<T> may be satisfied by a type that is not a signed integer type β for example, char (on a system where char is signed). So yeah, the plot twist is real. π
π 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)
mwah π β source: http://cppreference.com, version/date: 2024.06.10, page: std::signed_integral(3). bye bestie, go slay your type traits! π«Ά
π¦ 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