[llvm][Docs] Explain how to handle excessive formatting changes (#126239)
[llvm-project.git] / libcxx / test / std / utilities / charconv / charconv.syn / to_chars_result.pass.cpp
bloba7d9b086e591dc7236b3c3b7eed0419749ef7b6a
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // <charconv>
13 // struct to_chars_result
14 // friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
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.
21 #include <charconv>
23 #include <cassert>
24 #include <compare>
25 #include <concepts>
26 #include <system_error>
27 #include <type_traits>
29 #include "test_macros.h"
31 constexpr bool test() {
32 std::to_chars_result lhs{nullptr, std::errc{}};
33 #if TEST_STD_VER > 17
34 std::to_chars_result rhs{nullptr, std::errc{}};
35 assert(lhs == rhs);
36 assert(!(lhs != rhs));
37 #endif
38 auto [ptr, ec] = lhs;
39 static_assert(std::is_same_v<decltype(ptr), char*>);
40 assert(ptr == lhs.ptr);
41 static_assert(std::is_same_v<decltype(ec), std::errc>);
42 assert(ec == lhs.ec);
44 return true;
47 int main(int, char**) {
48 #if TEST_STD_VER > 17
49 static_assert(std::equality_comparable<std::to_chars_result>);
50 static_assert(!std::totally_ordered<std::to_chars_result>);
51 static_assert(!std::three_way_comparable<std::to_chars_result>);
52 #endif
54 assert(test());
55 static_assert(test());
57 return 0;