For the platform std :: chrono :: high_resolution_clock :: period :: num

I noticed that std::chrono::high_resolution_clock::period::num = 1for every system I tested. Is there any system (embedded, desktop, mobile or other) where it can be some other number? (In such a system, 1 second will not be displayed in ticks.)

+2
source share
1 answer

There are three implementations std::chrono::high_resolution_clockthat I know of: Visual Studio, gcc, and clang (when used with libC ++).

All three of them have nanosecond accuracy ( std::chrono::high_resolution_clock::period::num = 1). For VS and libC ++ high_resolution_clockis of type-aliased up to steady_clock. On gcc, it is flattened with type system_clock.

, std::chrono::high_resolution_clock::period::num != 1, , 1 "". :

seconds high_resolution_clock::duration.

, seconds, high_resolution_clock::duration, :

using CT = common_type_t<seconds, high_resolution_clock::duration>;

, , CT nanoseconds.

+4

All Articles