brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · e96cd19 Raw
66 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <chrono>11// class year_month_weekday;12 13//  year_month_weekday() = default;14//  constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,15//                               const chrono::weekday_indexed& wdi) noexcept;16//17//  Effects:  Constructs an object of type year_month_weekday by initializing18//                y_ with y, m_ with m, and wdi_ with wdi.19//20//  constexpr chrono::year                       year() const noexcept;21//  constexpr chrono::month                     month() const noexcept;22//  constexpr chrono::weekday                 weekday() const noexcept;23//  constexpr unsigned                          index() const noexcept;24//  constexpr chrono::weekday_indexed weekday_indexed() const noexcept;25//  constexpr bool                                 ok() const noexcept;26 27#include <chrono>28#include <type_traits>29#include <cassert>30 31#include "test_macros.h"32 33int main(int, char**)34{35    using year               = std::chrono::year;36    using month              = std::chrono::month;37    using weekday            = std::chrono::weekday;38    using weekday_indexed    = std::chrono::weekday_indexed;39    using year_month_weekday = std::chrono::year_month_weekday;40 41    constexpr month January = std::chrono::January;42    constexpr weekday Tuesday = std::chrono::Tuesday;43 44    ASSERT_NOEXCEPT(year_month_weekday{});45    ASSERT_NOEXCEPT(year_month_weekday{year{1}, month{1}, weekday_indexed{Tuesday, 1}});46 47    constexpr year_month_weekday ym0{};48    static_assert( ym0.year()            == year{},            "");49    static_assert( ym0.month()           == month{},           "");50    static_assert( ym0.weekday()         == weekday{},         "");51    static_assert( ym0.index()           == 0,                 "");52    static_assert( ym0.weekday_indexed() == weekday_indexed{}, "");53    static_assert(!ym0.ok(),                                   "");54 55    constexpr year_month_weekday ym1{year{2019}, January, weekday_indexed{Tuesday, 1}};56    static_assert( ym1.year()            == year{2019},                  "");57    static_assert( ym1.month()           == January,                     "");58    static_assert( ym1.weekday()         == Tuesday,                     "");59    static_assert( ym1.index()           == 1,                           "");60    static_assert( ym1.weekday_indexed() == weekday_indexed{Tuesday, 1}, "");61    static_assert( ym1.ok(),                                             "");62 63 64  return 0;65}66