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//===----------------------------------------------------------------------===//
8
9// <chrono>
10
11// time_point
12
13// template <class Clock, class Duration1, class Duration2>
14// typename common_type<Duration1, Duration2>::type
15// operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
16
17#include <chrono>
18#include <cassert>
19
20#include "test_macros.h"
21
22int main(int, char**)
23{
24 typedef std::chrono::system_clock Clock;
25 typedef std::chrono::milliseconds Duration1;
26 typedef std::chrono::microseconds Duration2;
27 {
28 std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
29 std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
30 assert((t1 - t2) == Duration2(2995));
31 }
32#if TEST_STD_VER > 11
33 {
34 constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
35 constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
36 static_assert((t1 - t2) == Duration2(2995), "");
37 }
38#endif
39
40 return 0;
41}
42

source code of libcxx/test/std/time/time.point/time.point.nonmember/op_-time_point.pass.cpp