diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2018-08-29 23:02:15 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2018-08-29 23:02:15 +0000 |
| commit | d0ab67f7d02023482c5dc06fcc14ea8488929684 (patch) | |
| tree | e156128cfb602125efeedc531e33516f4b7d28cb /libcxx/test | |
| parent | 9397c2a23b3ec6bce89bb872f3934e56586ca3db (diff) | |
| download | bcm5719-llvm-d0ab67f7d02023482c5dc06fcc14ea8488929684.tar.gz bcm5719-llvm-d0ab67f7d02023482c5dc06fcc14ea8488929684.zip | |
Last week, someone noted that a couple of the time_point member functions were not constexpr. I looked, and they were right. They were made constexpr in p0505, so I looked at all the other bits in that paper to make sure that I didn't miss anything else. There were a couple methods in the synopsis that should have been marked constexpr, but the code was correct.
llvm-svn: 340992
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp | 20 | ||||
| -rw-r--r-- | libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp index ffe855ce903..5d616418ca5 100644 --- a/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp +++ b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp @@ -12,15 +12,35 @@ // time_point // time_point& operator+=(const duration& d); +// constexpr in c++17 #include <chrono> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool constexpr_test() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point<Clock, Duration> t(Duration(5)); + t += Duration(4); + return t.time_since_epoch() == Duration(9); +} +#endif + int main() { + { typedef std::chrono::system_clock Clock; typedef std::chrono::milliseconds Duration; std::chrono::time_point<Clock, Duration> t(Duration(3)); t += Duration(2); assert(t.time_since_epoch() == Duration(5)); + } + +#if TEST_STD_VER > 14 + static_assert(constexpr_test(), ""); +#endif } diff --git a/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp index acad1cfecb4..44d5d41106f 100644 --- a/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp +++ b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp @@ -12,15 +12,35 @@ // time_point // time_point& operator-=(const duration& d); +// constexpr in c++17 #include <chrono> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool constexpr_test() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point<Clock, Duration> t(Duration(5)); + t -= Duration(4); + return t.time_since_epoch() == Duration(1); +} +#endif + int main() { + { typedef std::chrono::system_clock Clock; typedef std::chrono::milliseconds Duration; std::chrono::time_point<Clock, Duration> t(Duration(3)); t -= Duration(2); assert(t.time_since_epoch() == Duration(1)); + } + +#if TEST_STD_VER > 14 + static_assert(constexpr_test(), ""); +#endif } |

