Home | History | Annotate | Download | only in time.point.nonmember
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <chrono>
     11 
     12 // time_point
     13 
     14 // template <class Clock, class Duration1, class Rep2, class Period2>
     15 //   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
     16 //   operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
     17 
     18 // template <class Rep1, class Period1, class Clock, class Duration2>
     19 //   time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
     20 //   operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
     21 
     22 #include <chrono>
     23 #include <cassert>
     24 
     25 #include "test_macros.h"
     26 
     27 int main()
     28 {
     29     typedef std::chrono::system_clock Clock;
     30     typedef std::chrono::milliseconds Duration1;
     31     typedef std::chrono::microseconds Duration2;
     32     {
     33     std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     34     std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
     35     assert(t2.time_since_epoch() == Duration2(3005));
     36     t2 = Duration2(6) + t1;
     37     assert(t2.time_since_epoch() == Duration2(3006));
     38     }
     39 #if TEST_STD_VER > 11
     40     {
     41     constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     42     constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
     43     static_assert(t2.time_since_epoch() == Duration2(3005), "");
     44     constexpr std::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1;
     45     static_assert(t3.time_since_epoch() == Duration2(3006), "");
     46     }
     47 #endif
     48 }
     49