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
9// UNSUPPORTED: c++03, c++11, c++14
10
11// <charconv>
12
13// struct from_chars_result
14// friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
15
16// [charconv.syn]/2
17// The types to_chars_result and from_chars_result have the data members and
18// special members specified above. They have no base classes or members other
19// than those specified.
20
21#include <charconv>
22
23#include <cassert>
24#include <compare>
25#include <concepts>
26
27#include "test_macros.h"
28
29constexpr bool test() {
30 std::from_chars_result lhs{.ptr: nullptr, .ec: std::errc{}};
31#if TEST_STD_VER > 17
32 std::from_chars_result rhs{nullptr, std::errc{}};
33 assert(lhs == rhs);
34 assert(!(lhs != rhs));
35#endif
36 auto [ptr, ec] = lhs;
37 static_assert(std::is_same_v<decltype(ptr), const char*>);
38 assert(ptr == lhs.ptr);
39 static_assert(std::is_same_v<decltype(ec), std::errc>);
40 assert(ec == lhs.ec);
41
42 return true;
43}
44
45int main(int, char**) {
46#if TEST_STD_VER > 17
47 static_assert(std::equality_comparable<std::from_chars_result>);
48 static_assert(!std::totally_ordered<std::from_chars_result>);
49 static_assert(!std::three_way_comparable<std::from_chars_result>);
50#endif
51
52 assert(test());
53 static_assert(test());
54
55 return 0;
56}
57

source code of libcxx/test/std/utilities/charconv/charconv.syn/from_chars_result.pass.cpp