Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      operator+, operator-(std::chrono::time_point)

      From cppreference.com
      <cpp‎ |chrono‎ |time point
       
       
      Date and time library
       
       
      Defined in header<chrono>
      (1)
      template<class C,class D1,class R2,class P2>

      time_point<C,typenamestd::common_type<D1, duration<R2,P2>>::type>
          operator+(const time_point<C,D1>& pt,

                     const duration<R2,P2>& d);
      (since C++11)
      (until C++14)
      template<class C,class D1,class R2,class P2>

      constexpr time_point<C,std::common_type_t<D1, duration<R2,P2>>>
          operator+(const time_point<C,D1>& pt,

                     const duration<R2,P2>& d);
      (since C++14)
      (2)
      template<class R1,class P1,class C,class D2>

      time_point<C,typenamestd::common_type<duration<R1,P1>,D2>::type>
          operator+(const duration<R1,P1>& d,

                     const time_point<C,D2>& pt);
      (since C++11)
      (until C++14)
      template<class R1,class P1,class C,class D2>

      constexpr time_point<C,std::common_type_t<duration<R1,P1>,D2>>
          operator+(const duration<R1,P1>& d,

                     const time_point<C,D2>& pt);
      (since C++14)
      (3)
      template<class C,class D1,class R2,class P2>

      time_point<C,typenamestd::common_type<D1, duration<R2,P2>>::type>
          operator-(const time_point<C,D1>& pt,

                     const duration<R2,P2>& d);
      (since C++11)
      (until C++14)
      template<class C,class D1,class R2,class P2>

      constexpr time_point<C,std::common_type_t<D1, duration<R2,P2>>>
          operator-(const time_point<C,D1>& pt,

                     const duration<R2,P2>& d);
      (since C++14)
      (4)
      template<class C,class D1,class D2>

      typenamestd::common_type<D1,D2>::type
          operator-(const time_point<C,D1>& pt_lhs,

                     const time_point<C,D2>& pt_rhs);
      (since C++11)
      (until C++14)
      template<class C,class D1,class D2>

      constexprstd::common_type_t<D1,D2>
          operator-(const time_point<C,D1>& pt_lhs,

                     const time_point<C,D2>& pt_rhs);
      (since C++14)

      Performs add and subtract operations involving atime_point.

      1,2) Applies the offsetd topt. Effectively returnsCT(pt.time_since_epoch()+ d), whereCT is the return type.
      3) Applies the offsetd topt in negative direction. Effectively returnsCT(pt.time_since_epoch()- d), whereCT is the return type.
      4) Computes the difference betweenpt_lhs andpt_rhs.

      Contents

      [edit]Parameters

      pt - a time point to apply the offset to
      d - a time offset
      pt_lhs, pt_rhs - time points to extract difference from

      [edit]Return value

      1-3) The time point that resulted from applying the offsetd.
      4) The duration between the time points.

      [edit]Exceptions

      May throw implementation-defined exceptions.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2739C++11pt- d behaved erratically for unsigneddurationsbehavior corrected

      [edit]See also

      modifies the time point by the given duration
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/time_point/operator_arith2&oldid=157504"

      [8]ページ先頭

      ©2009-2025 Movatter.jp