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 weekday;
12
13// constexpr unsigned c_encoding() const noexcept;
14
15#include <chrono>
16#include <cassert>
17#include <type_traits>
18#include <utility>
19
20#include "test_macros.h"
21
22using weekday = std::chrono::weekday;
23
24constexpr bool test() {
25 for (unsigned i = 0; i <= 10; ++i) {
26 weekday wd(i);
27 assert(wd.c_encoding() == (i == 7 ? 0 : i));
28 }
29
30 return true;
31}
32
33int main(int, char**) {
34 ASSERT_NOEXCEPT(std::declval<weekday&>().c_encoding());
35 ASSERT_SAME_TYPE(unsigned, decltype(std::declval<weekday&>().c_encoding()));
36
37 test();
38 static_assert(test());
39
40 return 0;
41}
42

source code of libcxx/test/std/time/time.cal/time.cal.weekday/time.cal.weekday.members/c_encoding.pass.cpp