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