std:: signed_integral
From cppreference.net
|
헤더에 정의됨
<concepts>
|
||
|
template
<
class
T
>
concept signed_integral = std:: integral < T > && std:: is_signed_v < T > ; |
(C++20부터) | |
signed_integral<T>
개념은
T
가 정수형(integral type)이고
std::
is_signed_v
<
T
>
가
true
인 경우에만 만족됩니다.
목차 |
참고 사항
signed_integral<T>
는
부호 있는 정수형
이 아닌 타입에 의해서도 만족될 수 있습니다. 예를 들어,
char
(시스템에서
char
가 부호 있는 경우)가 있습니다.
예제
이 코드 실행
#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 }
가능한 출력:
(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
참고문헌
- C++23 표준 (ISO/IEC 14882:2024):
-
- 18.4.7 산술 개념 [concepts.arithmetic]
- C++20 표준 (ISO/IEC 14882:2020):
-
- 18.4.7 산술 개념 [concepts.arithmetic]
참고 항목
|
(C++11)
|
타입이 정수형인지 확인합니다
(class template) |
|
(C++11)
|
타입이 부호 있는 산술 타입인지 확인합니다
(class template) |