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 // UNSUPPORTED: c++03, c++11, c++14, c++17 9 10 // <chrono> 11 // class year; 12 13 // constexpr year& operator++() noexcept; 14 // constexpr year operator++(int) noexcept; 15 16 17 #include <chrono> 18 #include <type_traits> 19 #include <cassert> 20 21 #include "test_macros.h" 22 23 template <typename Y> testConstexpr()24constexpr bool testConstexpr() 25 { 26 Y y1{10}; 27 if (static_cast<int>(++y1) != 11) return false; 28 if (static_cast<int>(y1++) != 11) return false; 29 if (static_cast<int>(y1) != 12) return false; 30 return true; 31 } 32 main(int,char **)33int main(int, char**) 34 { 35 using year = std::chrono::year; 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 static_assert(testConstexpr<year>(), ""); 43 44 for (int i = 11000; i <= 11020; ++i) 45 { 46 year yr(i); 47 assert(static_cast<int>(++yr) == i + 1); 48 assert(static_cast<int>(yr++) == i + 1); 49 assert(static_cast<int>(yr) == i + 2); 50 } 51 52 return 0; 53 } 54