std::litera...:operator""d(3)
okay so bestie, welcome to the std::litera...:operator""d(3) page from the C++ Standard Libary manual β yes, that's the manual name exactly as the header spells it, typo and all, and we are obsessed with the chaos ππ
πΈ NAME πΈ
std::literals::chrono_literals::operator""d β std::literals::chrono_literals::operator""d
(no bestie, you're not seeing double: the NAME section literally repeats it twice. periodt. π)
β¨ Synopsis β¨
Defined in header <chrono>
constexpr std::chrono::day operator ""d( unsigned long long d )
(since C++20)
noexcept;
Forms a std::chrono::day literal representing a day of the month in the calendar. It's (since C++20), so it's giving modern C++ main character energy β¨.
π₯ Parameters π₯
dβ the day value. That's it. The whole parameter. Iconic minimalism π .
π€ Return value π€
A std::chrono::day storing d. If d > 255, the stored value is unspecified.
bestie, that's the important caveat: over 255 and the standard is literally like βstored value? unspecified, idk herβ π so don't act surprised.
π οΈ Possible implementation π οΈ
constexpr std::chrono::day operator ""d(unsigned long long d) noexcept
{
return std::chrono::day(d);
}
π Notes π
This operator is declared in the namespace std::literals::chrono_literals, where both literals and chrono_literals are inline namespaces. Access to this operator can be gained with:
using namespace std::literals,using namespace std::chrono_literals, orusing namespace std::literals::chrono_literals.
In addition, within the namespace std::chrono, the directive using namespace literals::chrono_literals; is provided by the standard library, so that if a programmer uses using namespace std::chrono; to gain access to the classes in the chrono library, the corresponding literal operators become visible as well. iykyk π«Ά
π» Example π»
// Run this code
#include <chrono>
#include <iostream>
int main()
{
using namespace std::literals::chrono_literals;
std::cout << static_cast<unsigned>(42d) << '\t' << 42d << '\n'
<< static_cast<unsigned>(256d) << '\t' << 256d << '\n' // unspecified
<< static_cast<unsigned>(298d) << '\t' << 298d << '\n';
// unspecified
}
this example ate, no notes π₯
π¨οΈ Possible output π¨οΈ
42 42 is not a valid day
0 00 is not a valid day
42 42 is not a valid day
π See also π
constructorβ constructs a day (public member function ofstd::chrono::day)operator unsignedβ retrieves the stored day value (public member function ofstd::chrono::day)
okay that's the whole page, bestie. source/version: http://cppreference.com; date: 2024.06.10; and the footer is still out here repeating std::litera...:operator""d(3) πβ¨
π¦ 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