1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===// 2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// 3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant// The LLVM Compiler Infrastructure 4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// 5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open 6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details. 7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// 8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===// 9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <chrono> 11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// time_point 13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 14c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// template <class Clock, class Duration1, class Rep2, class Period2> 15c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> 16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); 17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 18c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// template <class Rep1, class Period1, class Clock, class Duration2> 19c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type> 20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs); 21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <chrono> 23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert> 24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 25e619862dbf0c4a46db6e3d816bcafcfef6e85977Stephan T. Lavavej#include "test_macros.h" 26e619862dbf0c4a46db6e3d816bcafcfef6e85977Stephan T. Lavavej 27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main() 28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{ 29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant typedef std::chrono::system_clock Clock; 30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant typedef std::chrono::milliseconds Duration1; 31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant typedef std::chrono::microseconds Duration2; 32832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow { 33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant std::chrono::time_point<Clock, Duration1> t1(Duration1(3)); 34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5); 35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(t2.time_since_epoch() == Duration2(3005)); 36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant t2 = Duration2(6) + t1; 37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(t2.time_since_epoch() == Duration2(3006)); 38832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow } 39e619862dbf0c4a46db6e3d816bcafcfef6e85977Stephan T. Lavavej#if TEST_STD_VER > 11 40832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow { 41832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3)); 42832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5); 43832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow static_assert(t2.time_since_epoch() == Duration2(3005), ""); 44832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow constexpr std::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1; 45832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow static_assert(t3.time_since_epoch() == Duration2(3006), ""); 46832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow } 47832b304076afcd832a5ffe95281b46a7abdaf869Marshall Clow#endif 48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant} 49