std::regular(3)
π¦ std::regular π¦
okay so this is the C++ Standard Libary manual page for std::regular(3) β yes bestie, the concept is literally named std::regular, and the NAME section is just her name twice. iconic behavior, no notes π
π NAME π
std::regular - std::regular (self-titled queen, we love to see it π)
β¨ Synopsis β¨
Defined in header <concepts>.
template< class T >
(since C++20)
concept regular = std::semiregular<T> && std::equality_comparable<T>;
so the regular concept is the vibe check for a type being regular: the type is copyable, default constructible, and equality comparable. Itβs satisfied by types that behave similarly to built-in types like int, and that are comparable with ==. slay β
π Example π
// Run this code β go off, bestie:
// 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';
}
π Output π
Equal
4 4
π See also π
semiregularβ specifies that an object of a type can be copied, moved, swapped, and (C++20) default constructed. Itβs a (concept), iykyk π«Ά
π«Ά thatβs the whole page. source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::regular(3) β mwah, go be regular (the concept, not boring) πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms