std::chrono...weekday_last(3)
std::chrono...weekday_last(3) π
okay so bestie, you've landed on the std::chrono...weekday_last(3) page from the C++ Standard Libary manual (that's the manual name, fr fr). We're talking about the constructor with main character energy: std::chrono::weekday_last::weekday_last. Let's get into it. π¦
β¨ NAME β¨
std::chrono::weekday_last::weekday_lastβ yep, that's the NAME, and the description is alsostd::chrono::weekday_last::weekday_last. It's giving very "I am the page and the constructor" energy. π
πΈ Synopsis πΈ
Here's the exact signature, no cap:
constexpr explicit weekday_last( const std::chrono::weekday& wd )
(since C++20)
noexcept;
It's constexpr, it's explicit, it takes const std::chrono::weekday& wd, and it's noexcept;. Constructs a weekday_last object storing the weekday wd. β¨
π‘ Notes π‘
okay so there's a more convenient way to construct a weekday_last: use weekday's operator[], i.e., wd[std::chrono::last]. That's the shortcut, iykyk. π
π Example π
The original has this little // Run this code cue:
// Run this code
#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
const year_month_day ymd{floor<days>(system_clock::now())};
const weekday_last wdl{Sunday[last]}; // A last Sunday of a month
const year_month_day last_sun{ymd.year() / ymd.month() / wdl};
std::cout << "The last Sunday of current month falls on "
<< (int)last_sun.year() << '/'
<< (unsigned)last_sun.month() << '/'
<< (unsigned)last_sun.day() << '\n';
}
slay. π
Possible output:
The last Sunday of current month falls on 2021/9/26
And that's the whole vibe.
cute little sign-off: this page is from http://cppreference.com, dated 2024.06.10, and it's the std::chrono...weekday_last(3) page. bye bestie, go construct something iconic π«Άπ
π¦ 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