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_day;
13
14 // year_month_day() = default;
15 // constexpr year_month_day(const chrono::year& y, const chrono::month& m,
16 // const chrono::day& d) noexcept;
17 //
18 // Effects: Constructs an object of type year_month_day by initializing
19 // y_ with y, m_ with m, and d_ with d.
20 //
21 // constexpr chrono::year year() const noexcept;
22 // constexpr chrono::month month() const noexcept;
23 // constexpr chrono::day day() const noexcept;
24 // constexpr bool ok() const noexcept;
25
26 #include <chrono>
27 #include <type_traits>
28 #include <cassert>
29
30 #include "test_macros.h"
31
main()32 int main()
33 {
34 using year = std::chrono::year;
35 using month = std::chrono::month;
36 using day = std::chrono::day;
37 using year_month_day = std::chrono::year_month_day;
38
39 ASSERT_NOEXCEPT(year_month_day{});
40 ASSERT_NOEXCEPT(year_month_day{year{1}, month{1}, day{1}});
41
42 constexpr month January = std::chrono::January;
43
44 constexpr year_month_day ym0{};
45 static_assert( ym0.year() == year{}, "");
46 static_assert( ym0.month() == month{}, "");
47 static_assert( ym0.day() == day{}, "");
48 static_assert(!ym0.ok(), "");
49
50 constexpr year_month_day ym1{year{2019}, January, day{12}};
51 static_assert( ym1.year() == year{2019}, "");
52 static_assert( ym1.month() == January, "");
53 static_assert( ym1.day() == day{12}, "");
54 static_assert( ym1.ok(), "");
55
56 }
57