std:: integral
From cppreference.net
C++
Concepts library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||
|
헤더 파일에 정의됨
<concepts>
|
||
|
template
<
class
T
>
concept integral = std:: is_integral_v < T > ; |
(C++20부터) | |
개념
integral
<
T
>
는
T
가 정수형(integral type)일 때에만 만족됩니다.
예제
이 코드 실행
#include <concepts> #include <iostream> void print(std::integral auto i) { std::cout << "Integral: " << i << '\n'; } void print(auto x) { std::cout << "Non-integral: " << x << '\n'; } int main() { std::cout << std::boolalpha; static_assert(std::integral<bool>); print(true); static_assert(std::integral<char>); print('o'); static_assert(std::integral<int>); print(007); static_assert( ! std::integral<double> ); print(2e2); static_assert( ! std::integral<decltype("")> ); print("∫∫∫"); }
출력:
Integral: true Integral: o Integral: 7 Non-integral: 200 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)
|
타입이 정수형 타입인지 검사합니다
(클래스 템플릿) |