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