1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // year_month() = default;
14 // constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept;
16 // Effects: Constructs an object of type year_month by initializing y_ with y, and m_ with m.
18 // constexpr chrono::year year() const noexcept;
19 // constexpr chrono::month month() const noexcept;
20 // constexpr bool ok() const noexcept;
23 #include <type_traits>
26 #include "test_macros.h"
30 using year
= std::chrono::year
;
31 using month
= std::chrono::month
;
32 using year_month
= std::chrono::year_month
;
34 ASSERT_NOEXCEPT(year_month
{});
35 ASSERT_NOEXCEPT(year_month
{year
{1}, month
{1}});
37 constexpr year_month ym0
{};
38 static_assert( ym0
.year() == year
{}, "");
39 static_assert( ym0
.month() == month
{}, "");
40 static_assert(!ym0
.ok(), "");
42 constexpr year_month ym1
{year
{2018}, std::chrono::January
};
43 static_assert( ym1
.year() == year
{2018}, "");
44 static_assert( ym1
.month() == std::chrono::January
, "");
45 static_assert( ym1
.ok(), "");
47 constexpr year_month ym2
{year
{2018}, month
{}};
48 static_assert( ym2
.year() == year
{2018}, "");
49 static_assert( ym2
.month() == month
{}, "");
50 static_assert(!ym2
.ok(), "");