名前空間
変種
操作

std::semiregular

提供: cppreference.com
< cpp‎ | concepts
ヘッダ <concepts> で定義
template <class T>
concept semiregular = std::copyable<T> && std::default_constructible<T>;
(C++20以上)

semiregular コンセプトはコピー可能かつデフォルト構築可能な型を表します。 これは int のような組み込み型と同様に動作する型によって満たされます。 ただし == を用いた比較をサポートする必要はありません。

[編集]

#include <concepts>
#include <iostream>
 
template<std::semiregular T>
struct Single {
    T value;
};
 
int main()
{
    Single<int> myInt1{4};
    Single<int> myInt2;
    myInt2 = myInt1;
 
    std::cout << myInt1.value << ' ' << myInt2.value << '\n';
}

出力:

4 4