Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::integral

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

      The conceptintegral<T> is satisfied if and only ifT is an integral type.

      [edit]Example

      Run this code
      #include <concepts>#include <iostream> void print(std::integralauto 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("∫∫∫");}

      Output:

      Integral: trueIntegral: oIntegral: 7Non-integral: 200Non-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]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/concepts/integral&oldid=177883"

      [8]ページ先頭

      ©2009-2025 Movatter.jp