libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

op_-time_point.pass.cpp (1244B)


      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 Duration2>
     15 //   typename common_type<Duration1, Duration2>::type
     16 //   operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
     17 
     18 #include <chrono>
     19 #include <cassert>
     20 
     21 #include "test_macros.h"
     22 
     23 int main()
     24 {
     25     typedef std::chrono::system_clock Clock;
     26     typedef std::chrono::milliseconds Duration1;
     27     typedef std::chrono::microseconds Duration2;
     28     {
     29     std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     30     std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
     31     assert((t1 - t2) == Duration2(2995));
     32     }
     33 #if TEST_STD_VER > 11
     34     {
     35     constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     36     constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
     37     static_assert((t1 - t2) == Duration2(2995), "");
     38     }
     39 #endif
     40 }