brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · d8b71c1 Raw
58 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 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// XFAIL: libcpp-has-no-experimental-tzdb12 13// <chrono>14 15// struct local_info {16//   static constexpr int unique      = 0;17//   static constexpr int nonexistent = 1;18//   static constexpr int ambiguous   = 2;19//20//   int result;21//   sys_info first;22//   sys_info second;23// };24 25// Validates whether:26// - The static members are present as static constexpr members.27// - The members are present as non-const members.28// - The struct is an aggregate.29 30#include <chrono>31#include <string>32#include <type_traits>33 34int main(int, char**) {35  {36    constexpr const int& result = std::chrono::local_info::unique;37    static_assert(result == 0);38  }39  {40    constexpr const int& result = std::chrono::local_info::nonexistent;41    static_assert(result == 1);42  }43  {44    constexpr const int& result = std::chrono::local_info::ambiguous;45    static_assert(result == 2);46  }47 48  static_assert(std::is_aggregate_v<std::chrono::local_info>);49 50  std::chrono::local_info local_info{.result = 0, .first = std::chrono::sys_info{}, .second = std::chrono::sys_info{}};51 52  [[maybe_unused]] int& result                   = local_info.result;53  [[maybe_unused]] std::chrono::sys_info& first  = local_info.first;54  [[maybe_unused]] std::chrono::sys_info& second = local_info.second;55 56  return 0;57}58