58 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <chrono>10 11// duration12 13// duration& operator%=(const rep& rhs)14 15#include <chrono>16#include <cassert>17 18#include "test_macros.h"19 20class NotARep {};21 22typedef std::chrono::seconds Duration;23Duration operator%=(Duration d, NotARep) { return d; }24 25#if TEST_STD_VER > 1426constexpr bool test_constexpr()27{28 std::chrono::seconds s(11);29 s %= 3;30 return s.count() == 2;31}32#endif33 34int main(int, char**)35{36 {37 std::chrono::microseconds us(11);38 us %= 3;39 assert(us.count() == 2);40 }41 42#if TEST_STD_VER > 1443 static_assert(test_constexpr(), "");44#endif45 46#if TEST_STD_VER >= 1147 { // This is PR#4113048 Duration d(5);49 NotARep n;50 d %= n;51 assert(d.count() == 5);52 }53#endif54 55 56 return 0;57}58