Namespaces
Variants

std:: unsigned_integral

From cppreference.net
헤더에 정의됨 <concepts>
template < class T >
concept unsigned_integral = std:: integral < T > && ! std:: signed_integral < T > ;
(C++20부터)

unsigned_integral<T> 개념은 T 가 정수 타입이고 std:: is_signed_v < T > false 인 경우에만 충족됩니다.

목차

참고 사항

unsigned_integral<T> 부호 없는 정수 타입 이 아닌 타입에 의해 충족될 수 있습니다, 예를 들어 bool 과 같은 경우입니다.

예제

#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]

참고 항목

타입이 정수형인지 검사합니다
(class template)
(C++11)
타입이 부호 있는 산술 타입인지 검사합니다
(class template)