Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::chrono::clock_cast

      From cppreference.com
      <cpp‎ |chrono
       
       
      Date and time library
      Time point
      (C++11)
      clock_cast
      (C++20)
      Duration
      (C++11)
      Clocks
      (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)
       
      Defined in header<chrono>
      template<class Dest,class Source,class Duration>
      auto clock_cast(conststd::chrono::time_point<Source, Duration>& t);
      (since C++20)

      Converts the time pointt of a clockSource to an equivalent time point of the clockDest, usingstd::chrono::system_clock and/orstd::chrono::utc_clock as intermediaries if necessary.

      • If the expressionstd::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.
      1)std::chrono::clock_time_conversion<Dest,std::chrono::system_clock>{}(
         std::chrono::clock_time_conversion<std::chrono::system_clock, Source>{}(t))
      2)std::chrono::clock_time_conversion<Dest,std::chrono::utc_clock>{}(
         std::chrono::clock_time_conversion<std::chrono::utc_clock, Source>{}(t))
      • 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.
      1)std::chrono::clock_time_conversion<Dest,std::chrono::utc_clock>{}(

         std::chrono::clock_time_conversion<std::chrono::utc_clock,std::chrono::system_clock>{}(

             std::chrono::clock_time_conversion<std::chrono::system_clock, Source>{}(t)))
      2)std::chrono::clock_time_conversion<Dest,std::chrono::system_clock>{}(

         std::chrono::clock_time_conversion<std::chrono::system_clock,std::chrono::utc_clock>{}(

             std::chrono::clock_time_conversion<std::chrono::utc_clock, Source>{}(t)))
      • Otherwise, this function does not participate in overload resolution.

      [edit]Return value

      The result of the conversion, determined as described above.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      traits class defining how to convert time points of one clock to another
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/clock_cast&oldid=145790"

      [8]ページ先頭

      ©2009-2025 Movatter.jp