home | help
std::unsigned_integral(3)      C++ Standard Libary     std::unsigned_integral(3)

NAME
     std::unsigned_integral - std::unsigned_integral

Synopsis
	Defined in header <concepts>
	template< class T >
	concept        unsigned_integral       =       std::integral<T>       &&
     (since C++20)
	!std::signed_integral<T>;

	The concept unsigned_integral<T> is satisfied if and only if T is an in-
     tegral type
	and std::is_signed_v<T> is false.

Notes
	unsigned_integral<T> may be satisfied by a type that is not an	unsigned
     integer
	type, for example, bool.

Example
     // Run this code

      #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 inte-
     gral\n";
      }

      void test(std::unsigned_integral auto x, std::string_view text = "")
      {
	  std::cout << text << " (" + (text == "") << x << ") is an unsigned in-
     tegral\n";
      }

      void test(auto x, std::string_view text = "")
      {
	  std::cout << text << " (" + (text == "")  <<	x  <<  ")  is  non-inte-
     gral\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("a<<a<<");	      // 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
      (a<<a<<) is 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)

http://cppreference.com 	   2024.06.10	       std::unsigned_integral(3)

home | help