std::signed_integral(3) | C++ Standard Libary | std::signed_integral(3) |
NAME¶
std::signed_integral - std::signed_integral
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.
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¶
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)
2022.07.31 | http://cppreference.com |