std::chrono::clock_cast

From cppreference.com
< cpp‎ | chrono
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)
 
Date and time utilities
Time point
(C++11)
clock_cast
(C++20)
Duration
(C++11)
Clocks
(C++11)      
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Time of day
(C++20)(C++20)
(C++20)(C++20)
(C++20)

Calendars
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
Time zones
(C++20)
(C++20)
(C++20)
chrono I/O
(C++20)
C-style date and time
 
Defined in header <chrono>
template <class Dest, class Source, class Duration>
auto clock_cast(const std::chrono::time_point<Source, Duration>& t);
(since C++20)

Converts the time point t of a clock Source to an equivalent time point of the clock Dest, using std::chrono::system_clock and/or std::chrono::utc_clock as intermediaries if necessary.

  • If the expression std::chrono::clock_time_conversion<Dest, Source>{}(t) is well-formed, returns the result of that expression.
  • Otherwise, if at least one of the following two expressions are well-formed, then
  • If both expressions are well-formed, the conversion is ambiguous, and the program is ill-formed.
  • Otherwise, exactly one of the two expressions is well-formed; the result of that expression is returned.
  • Otherwise, if at least one of the following two expressions are well-formed, then
  • If both expressions are well-formed, the conversion is ambiguous, and the program is ill-formed.
  • Otherwise, exactly one of the two expressions is well-formed; the result of that expression is returned.
  • Otherwise, this function does not participate in overload resolution.

Return value

The result of the conversion, determined as described above.

Example

See also

traits class defining how to convert time points of one clock to another
(class template)