Skip to content
Closed
Changes from 1 commit
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
Next Next commit
Change _Literal_zero constructor to use pointer to _Literal_zero
This means that `std::is_constructible_v<_Literal_zero, int>` is
now false, and thus libraries like Catch2 can detect the difference
between a type comparable with `int`, and type comparable only
with literal `0`. This then lets it handle expressions like
`(a <=> b) == 0` inside `REQUIRE`.
  • Loading branch information
horenmar committed Jan 20, 2024
commit dd2c2777e64c6a0a7fd0503182db1344663af7a3
5 changes: 3 additions & 2 deletions stl/inc/compare
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ _STD_BEGIN
void _Literal_zero_is_expected();

struct _Literal_zero {
template <class _Ty, enable_if_t<is_same_v<_Ty, int>, int> = 0>
consteval _Literal_zero(_Ty _Zero) noexcept {
consteval _Literal_zero(_Literal_zero* _Zero) noexcept {
// Can't use _STL_VERIFY because this is a core header
if (_Zero != 0) {
_Literal_zero_is_expected();
}
}
template <class _Ty, enable_if_t<!is_same_v<_Ty, int>, int> = 0>
_Literal_zero( _Ty ) = delete;
};

using _Compare_t = signed char;
Expand Down