[AArch64] Generate zeroing forms of certain SVE2.2 instructions (8/11) (#116834)
[llvm-project.git] / libcxx / test / std / time / time.point / time.point.nonmember / op_-duration.pass.cpp
blob80e9d04a769fde388c5fbfebcf303e41f2204a65
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <chrono>
11 // time_point
13 // template <class Clock, class Duration1, class Rep2, class Period2>
14 // time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
15 // operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
17 #include <chrono>
18 #include <cassert>
19 #include <cstdint>
21 #include "test_macros.h"
23 template <class D>
24 void test2739() // LWG2739
26 typedef std::chrono::time_point<std::chrono::system_clock> TimePoint;
27 typedef std::chrono::duration<D> Dur;
28 const Dur d(5);
29 TimePoint t0 = std::chrono::system_clock::from_time_t(200);
30 TimePoint t1 = t0 - d;
31 assert(t1 < t0);
34 int main(int, char**)
36 typedef std::chrono::system_clock Clock;
37 typedef std::chrono::milliseconds Duration1;
38 typedef std::chrono::microseconds Duration2;
40 std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
41 std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
42 assert(t2.time_since_epoch() == Duration2(2995));
44 #if TEST_STD_VER > 11
46 constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
47 constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
48 static_assert(t2.time_since_epoch() == Duration2(2995), "");
50 #endif
51 test2739<std::int32_t>();
52 test2739<std::uint32_t>();
54 return 0;