Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
#include "test_macros.h"

// class gps_clock
using rep = std::chrono::gps_clock::rep;
using period = std::chrono::gps_clock::period;
using duration = std::chrono::gps_clock::duration;
using time_point = std::chrono::gps_clock::time_point;
[[maybe_unused]] constexpr bool is_steady = std::chrono::gps_clock::is_steady;
using rep = std::chrono::gps_clock::rep;
using period = std::chrono::gps_clock::period;
using duration = std::chrono::gps_clock::duration;
using time_point = std::chrono::gps_clock::time_point;

[[maybe_unused]] constexpr std::same_as<const bool> decltype(auto) is_steady = std::chrono::gps_clock::is_steady;

// Tests the values. part of them are implementation defined.
LIBCPP_STATIC_ASSERT(std::same_as<rep, std::chrono::utc_clock::rep>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main(int, char**)
static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
static_assert((std::is_same<C::period, C::duration::period>::value), "");
static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
static_assert(C::is_steady || !C::is_steady, "");
static_assert(std::is_same<decltype(C::is_steady), const bool>::value, "");
test(std::chrono::high_resolution_clock::is_steady);
Copy link
Contributor Author

@PaulXiCao PaulXiCao Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does someone know what the line test(...::is_steady); is supposed to test?
Incase it is just testing that the member exists it is probably already enough to have the static_assert line above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_steady tests whether the clock is steady. This means the clock has no time jumps. For some clocks the Standard requires them to be steady, for others it's implementation defined. The [time.clock] has the information. When unspecified we need a LIBCPP_ASSERT to validate the value libc++ uses.


return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int, char**)
static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
static_assert((std::is_same<C::period, C::duration::period>::value), "");
static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
static_assert(C::is_steady, "");
static_assert(std::is_same<decltype(C::is_steady), const bool>::value && C::is_steady, "");
test(std::chrono::steady_clock::is_steady);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int, char**)
static_assert((std::is_same<C::period, C::duration::period>::value), "");
static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
static_assert((std::is_same<C::time_point::clock, C>::value), "");
static_assert((C::is_steady || !C::is_steady), "");
static_assert(std::is_same<decltype(C::is_steady), const bool>::value, "");
test(std::chrono::system_clock::is_steady);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
#include "test_macros.h"

// class tai_clock
using rep = std::chrono::tai_clock::rep;
using period = std::chrono::tai_clock::period;
using duration = std::chrono::tai_clock::duration;
using time_point = std::chrono::tai_clock::time_point;
[[maybe_unused]] constexpr bool is_steady = std::chrono::tai_clock::is_steady;
using rep = std::chrono::tai_clock::rep;
using period = std::chrono::tai_clock::period;
using duration = std::chrono::tai_clock::duration;
using time_point = std::chrono::tai_clock::time_point;

[[maybe_unused]] constexpr std::same_as<const bool> decltype(auto) is_steady = std::chrono::tai_clock::is_steady;

// Tests the values. part of them are implementation defined.
LIBCPP_STATIC_ASSERT(std::same_as<rep, std::chrono::utc_clock::rep>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
#include "test_macros.h"

// class utc_clock
using rep = std::chrono::utc_clock::rep;
using period = std::chrono::utc_clock::period;
using duration = std::chrono::utc_clock::duration;
using time_point = std::chrono::utc_clock::time_point;
[[maybe_unused]] constexpr bool is_steady = std::chrono::utc_clock::is_steady;
using rep = std::chrono::utc_clock::rep;
using period = std::chrono::utc_clock::period;
using duration = std::chrono::utc_clock::duration;
using time_point = std::chrono::utc_clock::time_point;

[[maybe_unused]] constexpr std::same_as<const bool> decltype(auto) is_steady = std::chrono::utc_clock::is_steady;

// Tests the values. Some of them are implementation-defined.
LIBCPP_STATIC_ASSERT(std::same_as<rep, std::chrono::system_clock::rep>);
Expand Down