Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::regular

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

      Theregular concept specifies that a type isregular, that is, it is copyable, default constructible, and equality comparable. It is satisfied by types that behave similarly to built-in types likeint, and that are comparable with==.

      [edit]Example

      Run this code
      #include <concepts>#include <iostream> template<std::regular T>struct Single{    T value;friendbool operator==(const Single&,const Single&)=default;}; int main(){    Single<int> myInt1{4};    Single<int> myInt2;    myInt2= myInt1; if(myInt1== myInt2)std::cout<<"Equal\n"; std::cout<< myInt1.value<<' '<< myInt2.value<<'\n';}

      Output:

      Equal4 4

      [edit]References

      • C++23 standard (ISO/IEC 14882:2024):
      • 18.6 Object concepts [concepts.object]
      • C++20 standard (ISO/IEC 14882:2020):
      • 18.6 Object concepts [concepts.object]

      [edit]See also

      specifies that an object of a type can be copied, moved, swapped, and default constructed
      (concept)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/concepts/regular&oldid=177897"

      [8]ページ先頭

      ©2009-2025 Movatter.jp