| 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 |
// duration |
| 12 |
|
| 13 |
// template <class Rep1, class Period, class Rep2> |
| 14 |
// constexpr |
| 15 |
// duration<typename common_type<Rep1, Rep2>::type, Period> |
| 16 |
// operator/(const duration<Rep1, Period>& d, const Rep2& s); |
| 17 |
|
| 18 |
#include <chrono> |
| 19 |
#include <cassert> |
| 20 |
|
| 21 |
#include "test_macros.h" |
| 22 |
#include "../../rep.h" |
| 23 |
|
| 24 |
int main(int, char**) |
| 25 |
{ |
| 26 |
{ |
| 27 |
typedef std::chrono::nanoseconds Dur; |
| 28 |
Dur ns(15); |
| 29 |
ASSERT_SAME_TYPE(Dur, decltype(ns / 5)); |
| 30 |
ns = ns / 5; |
| 31 |
assert(ns.count() == 3); |
| 32 |
} |
| 33 |
#if TEST_STD_VER >= 11 |
| 34 |
{ |
| 35 |
constexpr std::chrono::nanoseconds ns(15); |
| 36 |
constexpr std::chrono::nanoseconds ns2 = ns / 5; |
| 37 |
static_assert(ns2.count() == 3, ""); |
| 38 |
} |
| 39 |
#endif |
| 40 |
|
| 41 |
#if TEST_STD_VER >= 11 |
| 42 |
{ // This is PR#41130 |
| 43 |
typedef std::chrono::nanoseconds Duration; |
| 44 |
Duration d(5); |
| 45 |
NotARep n; |
| 46 |
ASSERT_SAME_TYPE(Duration, decltype(d / n)); |
| 47 |
d = d / n; |
| 48 |
assert(d.count() == 5); |
| 49 |
} |
| 50 |
#endif |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |