std::chrono...ration::zero(3)

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

πŸŽ€ NAME πŸŽ€

Hey bestie πŸ’– welcome to the std::chrono...ration::zero(3) page from the C++ Standard Libary. std::chrono::duration::zero β€” literally std::chrono::duration::zero. That's the whole name, no notes, just main-character energy πŸ‘‘.

πŸ¦‹ Synopsis πŸ¦‹

static constexpr duration zero();           (until C++20)
static constexpr duration zero() noexcept;  (since C++20)

Returns a zero-length duration ✨.

If the representation rep of the duration requires some other implementation to return a zero-length duration, std::chrono::duration_values can be specialized to return the desired value. Lowkey powerful, ngl 🫢.

🌸 Parameters 🌸

(none) β€” literally nobody, bestie πŸ™ˆ.

πŸ’… Return value πŸ’…

Returns duration(std::chrono::duration_values<rep>::zero()). Periodt πŸ’–.

πŸ”₯ Example πŸ”₯

This is the code, bestie β€” run it and watch the zeroes line up:

// Run this code

#include <chrono>
#include <ratio>

template<typename X, typename Y>
using dura = std::chrono::duration<X, Y>;

static_assert
(
    (std::chrono::hours::zero() == std::chrono::nanoseconds::zero()) &&
    (dura<short, std::nano>::zero() == dura<int, std::deci>::zero()) &&
    (dura<short, std::deca>::zero() == dura<long, std::exa>::zero()) &&
    (dura<long, std::atto>::zero().count() == dura<float, std::exa>::zero().count())
);

int main() {}

The static_assert is doing the absolute most, and it ate πŸ”₯.

🌈 See also 🌈

  • min β€” returns the special duration value min; [static] (public static member function) πŸ’œ
  • max β€” returns the special duration value max; [static] (public static member function) πŸ’œ

Source/version + date: http://cppreference.com, 2024.06.10. Bye bestie β€” go return zero and serve absolutely nothing (duration-wise) πŸ’…βœ¨

πŸ“¦ where this page comes from