Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 19 additions & 2 deletions stl/inc/compare
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,25 @@ _STL_DISABLE_CLANG_WARNINGS
#undef new

_STD_BEGIN
using _Literal_zero = decltype(nullptr);
using _Compare_t = signed char;
struct partial_ordering;
struct weak_ordering;
struct strong_ordering;
Comment thread
fsb4000 marked this conversation as resolved.
Resolved

void _Literal_zero_is_expected();

struct _Literal_zero {

Comment thread
fsb4000 marked this conversation as resolved.
Resolved
consteval _Literal_zero(int _Zero) noexcept {
// Can't use _STL_VERIFY because this is a core header
if (_Zero != 0) {
_Literal_zero_is_expected();
}
}

template <class _Ty, class = enable_if_t<!_Is_any_of_v<_Ty, int, partial_ordering, weak_ordering, strong_ordering>>>
Comment thread
fsb4000 marked this conversation as resolved.
Resolved
Comment thread
fsb4000 marked this conversation as resolved.
Resolved
_Literal_zero(_Ty) = delete;
};
using _Compare_t = signed char;
Comment thread
fsb4000 marked this conversation as resolved.
Resolved

// These "pretty" enumerator names are safe since they reuse names of user-facing entities.
enum class _Compare_eq : _Compare_t { equal = 0, equivalent = equal };
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/P0768R1_spaceship_operator/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <compare>
#include <type_traits>

#ifdef __clang__
#pragma clang diagnostic error "-Wzero-as-null-pointer-constant"
#endif // __clang__
Comment thread
fsb4000 marked this conversation as resolved.
Resolved

enum class comp { equal, less, greater, unordered };

template <comp Z, class T>
Expand Down