Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stl/inc/bitset
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,11 @@ public:
return _CSTD memcmp(&_Array[0], &_Right._Array[0], sizeof(_Array)) == 0;
}

#if !_HAS_CXX20
_NODISCARD bool operator!=(const bitset& _Right) const noexcept {
return !(*this == _Right);
}
#endif // !_HAS_CXX20

_NODISCARD bool test(size_t _Pos) const {
if (_Bits <= _Pos) {
Expand Down
3 changes: 3 additions & 0 deletions stl/inc/charconv
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ to_chars_result to_chars(char* _First, char* _Last, bool _Value, int _Base = 10)
struct from_chars_result {
const char* ptr;
errc ec;
#if _HAS_CXX20
_NODISCARD friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
#endif // _HAS_CXX20
};

// FUNCTION from_chars (STRING TO INTEGER)
Expand Down
8 changes: 8 additions & 0 deletions stl/inc/typeindex
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ public:
return *_Tptr == *_Right._Tptr;
}

#if _HAS_CXX20
_NODISCARD strong_ordering operator<=>(const type_index& _Right) const noexcept {
return *_Tptr == *_Right._Tptr ? strong_ordering::equal
: _Tptr->before(*_Right._Tptr) ? strong_ordering::less
: strong_ordering::greater;
}
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
_NODISCARD bool operator!=(const type_index& _Right) const noexcept {
return !(*this == _Right);
}
#endif // ^^^ !_HAS_CXX20 ^^^

_NODISCARD bool operator<(const type_index& _Right) const noexcept {
return _Tptr->before(*_Right._Tptr);
Expand Down
3 changes: 3 additions & 0 deletions stl/inc/xcharconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ _BITMASK_OPS(chars_format)
struct to_chars_result {
char* ptr;
errc ec;
#if _HAS_CXX20
_NODISCARD friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
#endif // _HAS_CXX20
};

_STD_END
Expand Down
33 changes: 33 additions & 0 deletions tests/std/tests/P1614R2_spaceship/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <array>
#include <cassert>
#include <charconv>
#include <compare>
#include <concepts>
#include <deque>
Expand All @@ -27,6 +28,8 @@
#include <system_error>
#include <thread>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
Expand Down Expand Up @@ -574,6 +577,36 @@ void ordering_test_cases() {
static_assert(std::is_same_v<std::char_traits<char32_t>::comparison_category, std::strong_ordering>);
static_assert(std::is_same_v<std::char_traits<wchar_t>::comparison_category, std::strong_ordering>);
}
{ // charconv
char c[7] = "123456";

std::from_chars_result a1{c + 6, std::errc{}};
std::from_chars_result a2{c + 6, std::errc{}};
std::from_chars_result a3{c + 6, std::errc::result_out_of_range};
std::from_chars_result a4{c + 4, std::errc{}};

assert(a1 == a2);
assert(a1 != a3);
assert(a1 != a4);

std::to_chars_result b1{c + 6, std::errc{}};
std::to_chars_result b2{c + 6, std::errc{}};
std::to_chars_result b3{c + 6, std::errc::value_too_large};
std::to_chars_result b4{c + 4, std::errc{}};

assert(b1 == b2);
assert(b1 != b3);
assert(b1 != b4);
}
{ // typeindex
std::type_index a1 = typeid(int);
std::type_index a2 = typeid(char);
std::type_index a3 = typeid(bool);
std::type_index a4 = typeid(int);
assert((a1 <=> a4) == std::strong_ordering::equal);
assert((a1 <=> a2) == std::strong_ordering::greater); // Implementation-specific assumption
assert((a1 <=> a3) == std::strong_ordering::less); // Implementation-specific assumption
}
{ // Strings library
const std::string a1 = "abcdef";
const std::string a2 = "abcdef";
Expand Down