std::regulär
Von cppreference.com
| Definiert in der Header-Datei <concepts> |
||
| template< class T > concept regulär = std::semiregular<T> && std::equality_comparable<T>; |
(seit C++20) | |
Das Konzept regulär spezifiziert, dass ein Typ *regulär* ist, das heißt, er ist kopierbar, standardkonstruierbar und gleichheitsvergleichbar. Es wird von Typen erfüllt, die sich ähnlich wie eingebaute Typen wie int verhalten und mit == vergleichbar sind.
[edit] Beispiel
Führen Sie diesen Code aus
#include <concepts> #include <iostream> template<std::regular T> struct Single { T value; friend bool 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'; }
Ausgabe
Equal 4 4
[edit] Referenzen
- 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] Siehe auch
| (C++20) |
gibt an, dass ein Objekt eines Typs kopiert, verschoben, vertauscht und standardkonstruiert werden kann (Konzept) |