A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/algorithm/../ranges/../concepts/regular.html below:

std::regular - cppreference.com

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

[edit] Example
#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';
}

Output:

[edit] References
[edit] See also specifies that an object of a type can be copied, moved, swapped, and default constructed
(concept) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4