std::signed_integral
From cppreference.com
Defined in header <concepts>
|
||
template < class T > concept signed_integral = std::integral<T> && std::is_signed_v<T>; |
(since C++20) | |
The concept signed_integral<T>
is satisfied if and only if T
is an integral type and std::is_signed_v<T> is true.
Notes
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).
Example
Run this code
#include <concepts> #include <iostream> void print(std::signed_integral auto i) { std::cout << "Signed integral: " << i << '\n'; } void print(std::unsigned_integral auto u) { std::cout << "Unsigned integral: " << u << '\n'; } void print(auto x) { std::cout << "Non-integral: " << x << '\n'; } int main() { print(42); // signed print(0xFull); // unsigned print(true); // unsigned print('A'); // platform-dependent print(4e-2); // non-integral (hex-float) print("∫∫∫"); // non-integral }
Possible output:
Signed integral: 42 Unsigned integral: 15 Unsigned integral: 1 Signed integral: A Non-integral: 0.04 Non-integral: ∫∫∫
See also
(C++11) |
checks if a type is an integral type (class template) |
(C++11) |
checks if a type is a signed arithmetic type (class template) |