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 // time_point& operator+=(const duration& d); 15 // constexpr in c++17 16 17 #include <chrono> 18 #include <cassert> 19 20 #include "test_macros.h" 21 22 #if TEST_STD_VER > 14 constexpr_test()23constexpr bool constexpr_test() 24 { 25 typedef std::chrono::system_clock Clock; 26 typedef std::chrono::milliseconds Duration; 27 std::chrono::time_point<Clock, Duration> t(Duration(5)); 28 t += Duration(4); 29 return t.time_since_epoch() == Duration(9); 30 } 31 #endif 32 main()33int main() 34 { 35 { 36 typedef std::chrono::system_clock Clock; 37 typedef std::chrono::milliseconds Duration; 38 std::chrono::time_point<Clock, Duration> t(Duration(3)); 39 t += Duration(2); 40 assert(t.time_since_epoch() == Duration(5)); 41 } 42 43 #if TEST_STD_VER > 14 44 static_assert(constexpr_test(), ""); 45 #endif 46 } 47