std::chrono...:month_day)(3)
π
std::chrono::operator==,(std::chrono::month_day) π
okay so bestie, this page is from the C++ Standard Libary manual (yes, thatβs the manual name, typo and all π). Itβs the whole glow-up for comparing std::chrono::month_day values. Two month_days walk into a compiler, and this operator tells you if theyβre matching. Iconic behavior, no cap β¨.
πΈ NAME πΈ
std::chrono::operator==,(std::chrono::month_day)βstd::chrono::operator==,(std::chrono::month_day)
π Synopsis π
Defined in header <chrono>:
constexpr bool operator==( const std::chrono::month_day& x,
const std::chrono::month_day& y )
noexcept; (1) (since C++20)
constexpr std::strong_ordering operator<=>( const std::chrono::month_day& x,
const std::chrono::month_day& y ) noexcept;
(2) (since C++20)
Compares two month_day values. Thatβs the whole assignment, and it ate π
.
The <, <=, >, >=, and != operators are synthesized from operator<=> and operator== respectively. Periodt. π
π Return value π
x.month() == y.month() && x.day() == y.day()x.month() <=> y.month() != 0 ? x.month() <=> y.month() : x.day() <=> y.day()
π¦ Example π¦
// Run this code
#include <chrono>
#include <iostream>
int main()
{
constexpr auto md1{std::chrono::August/15};
constexpr auto md2{std::chrono::month(8)/std::chrono::day(15)};
std::cout << std::boolalpha << (md1 == md2) << '\n';
static_assert(md1 <= md2);
}
Output:
true
source shoutout at the very end: this came from http://cppreference.com, version/date 2024.06.10, page std::chrono...:month_day)(3). Byeee, go compare your month-days responsibly π«Άπ
π¦ 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