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 // bool 16 // operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 17 18 // template <class Clock, class Duration1, class Duration2> 19 // bool 20 // operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 21 22 #include <chrono> 23 #include <cassert> 24 25 int main() 26 { 27 typedef std::chrono::system_clock Clock; 28 typedef std::chrono::milliseconds Duration1; 29 typedef std::chrono::microseconds Duration2; 30 typedef std::chrono::time_point<Clock, Duration1> T1; 31 typedef std::chrono::time_point<Clock, Duration2> T2; 32 33 { 34 T1 t1(Duration1(3)); 35 T1 t2(Duration1(3)); 36 assert( (t1 == t2)); 37 assert(!(t1 != t2)); 38 } 39 { 40 T1 t1(Duration1(3)); 41 T1 t2(Duration1(4)); 42 assert(!(t1 == t2)); 43 assert( (t1 != t2)); 44 } 45 { 46 T1 t1(Duration1(3)); 47 T2 t2(Duration2(3000)); 48 assert( (t1 == t2)); 49 assert(!(t1 != t2)); 50 } 51 { 52 T1 t1(Duration1(3)); 53 T2 t2(Duration2(3001)); 54 assert(!(t1 == t2)); 55 assert( (t1 != t2)); 56 } 57 58 #if _LIBCPP_STD_VER > 11 59 { 60 constexpr T1 t1(Duration1(3)); 61 constexpr T1 t2(Duration1(3)); 62 static_assert( (t1 == t2), ""); 63 static_assert(!(t1 != t2), ""); 64 } 65 { 66 constexpr T1 t1(Duration1(3)); 67 constexpr T1 t2(Duration1(4)); 68 static_assert(!(t1 == t2), ""); 69 static_assert( (t1 != t2), ""); 70 } 71 { 72 constexpr T1 t1(Duration1(3)); 73 constexpr T2 t2(Duration2(3000)); 74 static_assert( (t1 == t2), ""); 75 static_assert(!(t1 != t2), ""); 76 } 77 { 78 constexpr T1 t1(Duration1(3)); 79 constexpr T2 t2(Duration2(3001)); 80 static_assert(!(t1 == t2), ""); 81 static_assert( (t1 != t2), ""); 82 } 83 #endif 84 } 85