1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 10 11 // <chrono> 12 // class year_month; 13 14 // year_month() = default; 15 // constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept; 16 // 17 // Effects: Constructs an object of type year_month by initializing y_ with y, and m_ with m. 18 // 19 // constexpr chrono::year year() const noexcept; 20 // constexpr chrono::month month() const noexcept; 21 // constexpr bool ok() const noexcept; 22 23 #include <chrono> 24 #include <type_traits> 25 #include <cassert> 26 27 #include "test_macros.h" 28 29 int main() 30 { 31 using year = std::chrono::year; 32 using month = std::chrono::month; 33 using year_month = std::chrono::year_month; 34 35 ASSERT_NOEXCEPT(year_month{}); 36 ASSERT_NOEXCEPT(year_month{year{1}, month{1}}); 37 38 constexpr year_month ym0{}; 39 static_assert( ym0.year() == year{}, ""); 40 static_assert( ym0.month() == month{}, ""); 41 static_assert(!ym0.ok(), ""); 42 43 constexpr year_month ym1{year{2018}, std::chrono::January}; 44 static_assert( ym1.year() == year{2018}, ""); 45 static_assert( ym1.month() == std::chrono::January, ""); 46 static_assert( ym1.ok(), ""); 47 48 constexpr year_month ym2{year{2018}, month{}}; 49 static_assert( ym2.year() == year{2018}, ""); 50 static_assert( ym2.month() == month{}, ""); 51 static_assert(!ym2.ok(), ""); 52 } 53