Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::unsigned_integral

      From cppreference.com
      <cpp‎ |concepts
       
       
      Concepts library
       
      Defined in header<concepts>
      template<class T>
      concept unsigned_integral=std::integral<T>&&!std::signed_integral<T>;
      (since C++20)

      The conceptunsigned_integral<T> is satisfied if and only ifT is an integral type andstd::is_signed_v<T> isfalse.

      Contents

      [edit]Notes

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

      [edit]Example

      Run this code
      #include <concepts>#include <iostream>#include <string_view> void test(std::signed_integralauto x,std::string_view text=""){std::cout<< text<<" ("+(text=="")<< x<<") is a signed integral\n";} void test(std::unsigned_integralauto 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}

      Possible output:

      (42) is a signed integral0xFULL (15) is an unsigned integral(A) is a signed integraltrue (1) is an unsigned integral4e-2 (0.04) is non-integral(∫∫) is non-integral

      [edit]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]

      [edit]See also

      checks if a type is an integral type
      (class template)[edit]
      (C++11)
      checks if a type is a signed arithmetic type
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/concepts/unsigned_integral&oldid=177885"

      [8]ページ先頭

      ©2009-2025 Movatter.jp