Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
josuttis_nm_c20_the_complete_guide.pdf
Скачиваний:
48
Добавлен:
27.03.2023
Размер:
5.85 Mб
Скачать

11.8 Other New Chrono Features

401

11.8 Other New Chrono Features

In addition to what I have described so far, the new chrono library adds the following features:

To check whether a type is a clock, a new type trait std::chrono::is_clock<> is provided together with its corresponding variable template std::chrono::is_clock_v<>. For example:

std::chrono::is_clock_v<std::chrono::system_clock>

// true

std::chrono::is_clock_v<std::chrono::local_t>

// false

The pseudo clock local_t yields false here because it does not provide the member function now().

• For durations and timepoints, operator<=> is defined.

11.9 Afternotes

The chrono library was developed by Howard Hinnant. When the basic part for durations and timepoints was standardized with C++11, the plan was already to extend this with support for dates, calendars, and timezones.

The chrono extension for C++20 was first proposed by Howard Hinnant in http://wg21.link/ p0355r0. The finally accepted wording for this extension was formulated by Howard Hinnant and Tomasz Kaminski in http://wg21.link/p0355r7.

A few minor fixes were added by Howard Hinnant in http://wg21.link/p1466r3 and by Tomasz Kaminski in http://wg21.link/p1650r0. The finally accepted wording for the integration of the chrono library with the formatting library was formulated by Victor Zverovich, Daniela Engert, and Howard Hinnant in http://wg21.link/p1361r2.

After finishing C++20, a few fixes were applied to fix the chrono extensions of the C++20 standard:

http://wg21.link/p2372 clarified the behavior of locale-dependent formatted output.

http://wg21.link/lwg3554 ensures that you can pass string literals as format to parse().

402

This page is intentionally left blank