Documentation Home

Explicitly convert a std::chrono::duration object to a specific std::chrono::duration instantiation.

template <class ToDuration, class Rep, class Period>
constexpr ToDuration duration_cast(const duration<Rep, Period>& d);


ToDuration must be an instantiation of std::chrono::duration.


The duration d converted to the duration type specified by ToDuration. This is done in such a way as to minimize any loss of precision resulting from conversions between different scales and representation types.


#include <chrono>

See Also