From cppreference.com
template<classT>conceptsigned_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
, for example, char (on a system where char is signed).
Example
Run this code
#include<concepts>#include<iostream>#include<string_view>voidtest(std::signed_integralautox,std::string_viewtext=""){std::cout<<text<<" ("+(text=="")<<x<<") is a signed integral\n";}voidtest(std::unsigned_integralautox,std::string_viewtext=""){std::cout<<text<<" ("+(text=="")<<x<<") is an unsigned integral\n";}voidtest(autox,std::string_viewtext=""){std::cout<<text<<" ("+(text=="")<<x<<") is non-integral\n";}intmain(){test(42);// signedtest(0xFULL,"0xFULL");// unsignedtest('A');// platform-dependenttest(true,"true");// unsignedtest(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 References
C++23 standard (ISO/IEC 14882:2024):
18.4.7 Arithmetic concepts [concepts.arithmetic]
C++20 standard (ISO/IEC 14882:2020):
18.4.7 Arithmetic concepts [concepts.arithmetic]
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)