BDE 4.14.0 Production release
|
Provide functionality of the corresponding C++ Standard header.
Canonical header: bsl_chrono.h
This component is for internal use only. Please include <bsl_chrono.h>
directly. This component imports symbols declared in the <chrono> header file implemented in the standard library provided by the compiler vendor.
This component provides a set of user-defined literals (UDL) to form bsl::chrono::duration
objects with various duration periods such as hours, minutes, seconds, milliseconds, microseconds and nanoseconds. The ud-suffixes are preceded with the _
symbol to distinguish between the bsl
-chrono's UDLs and the std
-chrono's UDLs introduced in the C++14 standard and implemented in the standard library. Note that bsl
-chrono's UDLs, unlike the std
-chrono's UDLs, can be used in a client's code if the current compiler supports the C++11 standard.
Also note that bsl
-chrono's UDL operators are declared in the bsl::literals::chrono_literals
namespace, where literals
and chrono_literals are inline namespaces. Access to these operators can be gained with either using namespace bsl::literals
, using namespace bsl::chrono_literals
or using namespace bsl::literals::chrono_literals
. But we recommend using namespace bsl::chrono_literals
to minimize the scope of the using declaration.
This feature has been provided by MSVC++ compiler since VS 2019 16.10. But that release was shipped with the following important note:
"While the STL generally provides all features on all supported versions of Windows, leap seconds and time zones (which change over time) require OS support that was added to Windows 10. Specifically, updating the leap second database requires Windows 10 version 1809 or later, and time zones require <tt>icu.dll</tt> which is provided by Windows 10 version 1903/19H1 or later. This applies to both client and server OSes; note that Windows Server 2019 is based on Windows 10 version 1809."
If the feature is used on a host that doesn't provide icu.dll
, an exception with "The specified module could not be found." message will be thrown. That is why this feature is disabled by default on Windows.
In this section we show intended use of this component.
This example demonstrates basic use of user-defined literal operators.
First, we provide an access to bsl
-chrono's UDLs.
Then, we construct two duration objects that represent a 24-hours and a half an hour time intervals using operator "" _h
.
Finally, stream the two objects to stdout
:
The streaming operator produces output in the following format on stdout
: