libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

ctor.pass.cpp (1981B)


      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 month_weekday;
     13 //   month_weekday represents the nth weekday of a month, of an as yet unspecified year.
     14 
     15 //  constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
     16 //    Effects:  Constructs an object of type month_weekday by initializing m_ with m, and wdi_ with wdi.
     17 //
     18 //  constexpr chrono::month                     month() const noexcept;
     19 //  constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
     20 //  constexpr bool                                 ok() const noexcept;
     21 
     22 #include <chrono>
     23 #include <type_traits>
     24 #include <cassert>
     25 
     26 #include "test_macros.h"
     27 
     28 int main()
     29 {
     30     using month_weekday   = std::chrono::month_weekday;
     31     using month           = std::chrono::month;
     32     using weekday         = std::chrono::weekday;
     33     using weekday_indexed = std::chrono::weekday_indexed;
     34 
     35     ASSERT_NOEXCEPT(month_weekday{month{1}, weekday_indexed{weekday{}, 1}});
     36 
     37     constexpr month_weekday md0{month{}, weekday_indexed{}};
     38     static_assert( md0.month()           == month{},           "");
     39     static_assert( md0.weekday_indexed() == weekday_indexed{}, "");
     40     static_assert(!md0.ok(),                                   "");
     41 
     42     constexpr month_weekday md1{std::chrono::January, weekday_indexed{std::chrono::Friday, 4}};
     43     static_assert( md1.month() == std::chrono::January,                              "");
     44     static_assert( md1.weekday_indexed() == weekday_indexed{std::chrono::Friday, 4}, "");
     45     static_assert( md1.ok(),                                                         "");
     46 }