forked from OSchip/llvm-project
[libc++] Adds (to|from)_chars_result operator==.
Implements part of P1614 The Mothership has Landed. Reviewed By: #libc, Quuxplusone, Mordante Differential Revision: https://reviews.llvm.org/D112366
This commit is contained in:
parent
4c94760f36
commit
3624c4d845
|
@ -25,6 +25,8 @@ Section,Description,Dependencies,Assignee,Complete
|
|||
| `[unique.ptr.special] <https://wg21.link/unique.ptr.special>`_,| unique_ptr,[comparisons.three.way],Unassigned,|Not Started|
|
||||
| `[util.smartptr.shared.cmp] <https://wg21.link/util.smartptr.shared.cmp>`_,| shared_ptr,[comparisons.three.way],Unassigned,|Not Started|
|
||||
| `[type.index.members] <https://wg21.link/type.index.members>`_,| type_index,None,Unassigned,|Not Started|
|
||||
| `[charconv.syn] <https://wg21.link/charconv.syn>`_,| to_chars_result,None,Mark de Wever,|Complete|
|
||||
| `[charconv.syn] <https://wg21.link/charconv.syn>`_,| from_chars_result,None,Mark de Wever,|Complete|
|
||||
| `[stacktrace.entry.cmp] <https://wg21.link/stacktrace.entry.cmp>`_,| stacktrace_entry,None,Unassigned,|Not Started|
|
||||
| `[stacktrace.basic.cmp] <https://wg21.link/stacktrace.basic.cmp>`_,| basic_stacktrace,[alg.three.way],Unassigned,|Not Started|
|
||||
| `[string.cmp] <https://wg21.link/string.cmp>`_,| `basic_string <https://reviews.llvm.org/D80895>`_,None,Christopher Di Bella,|In Progress|
|
||||
|
|
|
|
@ -25,6 +25,9 @@ struct _LIBCPP_TYPE_VIS from_chars_result
|
|||
{
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
# if _LIBCPP_STD_VER > 17
|
||||
_LIBCPP_HIDE_FROM_ABI friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
|
||||
# endif
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
|
|
@ -25,6 +25,9 @@ struct _LIBCPP_TYPE_VIS to_chars_result
|
|||
{
|
||||
char* ptr;
|
||||
errc ec;
|
||||
# if _LIBCPP_STD_VER > 17
|
||||
_LIBCPP_HIDE_FROM_ABI friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
|
||||
# endif
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace std {
|
|||
struct to_chars_result {
|
||||
char* ptr;
|
||||
errc ec;
|
||||
friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20
|
||||
};
|
||||
|
||||
to_chars_result to_chars(char* first, char* last, see below value,
|
||||
|
@ -56,6 +57,7 @@ namespace std {
|
|||
struct from_chars_result {
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20
|
||||
};
|
||||
|
||||
from_chars_result from_chars(const char* first, const char* last,
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: libcpp-no-concepts
|
||||
|
||||
// <charconv>
|
||||
|
||||
// struct from_chars_result
|
||||
// friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
|
||||
|
||||
#include <charconv>
|
||||
|
||||
#include <cassert>
|
||||
#include <compare>
|
||||
#include <concepts>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
constexpr bool test() {
|
||||
std::from_chars_result lhs{nullptr, std::errc{}};
|
||||
std::from_chars_result rhs{nullptr, std::errc{}};
|
||||
assert(lhs == rhs);
|
||||
assert(!(lhs != rhs));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
static_assert(std::equality_comparable<std::from_chars_result>);
|
||||
static_assert(!std::totally_ordered<std::from_chars_result>);
|
||||
static_assert(!std::three_way_comparable<std::from_chars_result>);
|
||||
|
||||
assert(test());
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: libcpp-no-concepts
|
||||
|
||||
// <charconv>
|
||||
|
||||
// struct to_chars_result
|
||||
// friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
|
||||
|
||||
#include <charconv>
|
||||
|
||||
#include <cassert>
|
||||
#include <compare>
|
||||
#include <concepts>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
constexpr bool test() {
|
||||
std::to_chars_result lhs{nullptr, std::errc{}};
|
||||
std::to_chars_result rhs{nullptr, std::errc{}};
|
||||
assert(lhs == rhs);
|
||||
assert(!(lhs != rhs));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
static_assert(std::equality_comparable<std::to_chars_result>);
|
||||
static_assert(!std::totally_ordered<std::to_chars_result>);
|
||||
static_assert(!std::three_way_comparable<std::to_chars_result>);
|
||||
|
||||
assert(test());
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue