brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · c08d23a Raw
47 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// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <chrono>11// class year;12 13// constexpr year operator+() const noexcept;14// constexpr year operator-() const noexcept;15 16#include <chrono>17#include <cassert>18#include <type_traits>19#include <utility>20 21#include "test_macros.h"22 23using year = std::chrono::year;24 25constexpr bool test() {26  for (int i = 10000; i <= 10020; ++i) {27    year yr(i);28    assert(static_cast<int>(+yr) == i);29    assert(static_cast<int>(-yr) == -i);30  }31 32  return true;33}34 35int main(int, char**) {36  ASSERT_NOEXCEPT(+std::declval<year>());37  ASSERT_NOEXCEPT(-std::declval<year>());38 39  ASSERT_SAME_TYPE(year, decltype(+std::declval<year>()));40  ASSERT_SAME_TYPE(year, decltype(-std::declval<year>()));41 42  test();43  static_assert(test());44 45  return 0;46}47