From cppreference.com
template<classT>conceptsemiregular=std::copyable<T>&&std::default_initializable<T>;(since C++20)The semiregular concept specifies that a type is both copyable and default constructible. It is satisfied by types that behave similarly to built-in types like int, except that they need not support comparison with ==.
Example
Run this code
#include<concepts>#include<iostream>template<std::semiregularT>// Credit Alexander Stepanov// concepts are requirements on T// Requirement on T: T is semiregular// T a(b); or T a = b; => copy constructor// T a; => default constructor// a = b; => assignmentstructSingle{Tvalue;// Aggregation initialization for Single behaves like following constructor:// explicit Single(const T& x) : value(x) {}// Implicitly declared special member functions behave like following definitions,// except that they may have additional properties:// Single(const Single& x) : value(x.value) {}// Single() {}// ~Single() {}// Single& operator=(const Single& x) { value = x.value; return *this; }// comparison operator is not defined; it is not required by `semiregular` concept// bool operator==(Single const& other) const = delete;};voidprint(std::semiregularautox){std::cout<<x.value<<'\n';}intmain(){Single<int>myInt1{4};// aggregate initialization: myInt1.value = 4Single<int>myInt2(myInt1);// copy constructorSingle<int>myInt3;// default constructormyInt3=myInt2;// copy assignment operator// myInt1 == myInt2; // Error: operator== is not definedprint(myInt1);// ok: Single<int> is a `semiregular` typeprint(myInt2);print(myInt3);}// Single<int> variables are destroyed hereOutput:
4 4 4 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]
See also