std::regular
提供: cppreference.com
ヘッダ <concepts> で定義
|
||
template <class T> concept regular = std::semiregular<T> && std::equality_comparable<T>; |
(C++20以上) | |
regular
コンセプトは型が普通である、つまり、コピー可能、デフォルト構築可能、および等しさを比較可能であることを表します。 これは int のような組み込み型と同様に振る舞い、 ==
で比較可能な型によって満たされます。
[編集] 例
Run this code
#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'; }
出力:
Equal 4 4