std::chrono...torunsigned(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, welcome to std::chrono...torunsigned(3) β€” straight outta the C++ Standard Libary manual, and yes, the title is doing the absolute most with that ellipsis ✨

  • std::chrono::month::operatorunsigned β€” yep, that's the name, and the page repeats it as std::chrono::month::operatorunsigned too. iconic behavior, no notes πŸ’…

✨ Synopsis ✨

constexpr explicit operator unsigned() const noexcept;  (since C++20)

It returns the month value stored in *this. that's the whole assignment, bestie 🫢

πŸŽ€ Return value πŸŽ€

The month value stored in *this. literally that. the month value, stored in *this, returned to you. slay πŸŽ€

🧚 Example 🧚

okay code time, let's get into it πŸ’–

       // Run this code

        #include <chrono>
        #include <iostream>

        int main()
        {
            constexpr std::chrono::month m{6};
            constexpr unsigned p = static_cast<unsigned>(m);
            constexpr unsigned q =
       static_cast<unsigned>(std::chrono::September);
            std::cout << "The month is: " << p << '\n'
                      << "September is: " << q << '\n';
        }

🌈 Output 🌈

The month is: 6
September is: 9

and that's the vibe 🌸


mwah πŸ’‹ this lil page is from http://cppreference.com, and the footer tea is dated 2024.06.10 β€” source/version and date mentioned, not copied, periodt πŸ’œ

πŸ“¦ where this page comes from