brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 26d0d36 Raw
59 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++1410 11// <charconv>12 13// struct from_chars_result14//   friend bool operator==(const from_chars_result&, const from_chars_result&) = default;15 16// [charconv.syn]/217// The types to_chars_result and from_chars_result have the data members and18// special members specified above. They have no base classes or members other19// than those specified.20 21#include <charconv>22 23#include <cassert>24#include <compare>25#include <concepts>26#include <system_error>27#include <type_traits>28 29#include "test_macros.h"30 31constexpr bool test() {32  std::from_chars_result lhs{nullptr, std::errc{}};33#if TEST_STD_VER > 1734  std::from_chars_result rhs{nullptr, std::errc{}};35  assert(lhs == rhs);36  assert(!(lhs != rhs));37#endif38  auto [ptr, ec] = lhs;39  static_assert(std::is_same_v<decltype(ptr), const char*>);40  assert(ptr == lhs.ptr);41  static_assert(std::is_same_v<decltype(ec), std::errc>);42  assert(ec == lhs.ec);43 44  return true;45}46 47int main(int, char**) {48#if TEST_STD_VER > 1749  static_assert(std::equality_comparable<std::from_chars_result>);50  static_assert(!std::totally_ordered<std::from_chars_result>);51  static_assert(!std::three_way_comparable<std::from_chars_result>);52#endif53 54  assert(test());55  static_assert(test());56 57  return 0;58}59