From dd2c2777e64c6a0a7fd0503182db1344663af7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 20 Jan 2024 10:50:11 +0100 Subject: [PATCH 1/2] 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`. --- stl/inc/compare | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stl/inc/compare b/stl/inc/compare index e35d1a3a4d0..d059bcf4eb4 100644 --- a/stl/inc/compare +++ b/stl/inc/compare @@ -28,13 +28,14 @@ _STD_BEGIN void _Literal_zero_is_expected(); struct _Literal_zero { - template , 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 , int> = 0> + _Literal_zero( _Ty ) = delete; }; using _Compare_t = signed char; From 94976202a677e43848d2b3cc5461f1421342974e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 20 Jan 2024 12:38:01 +0100 Subject: [PATCH 2/2] Fix formatting --- stl/inc/compare | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/compare b/stl/inc/compare index d059bcf4eb4..8cdd4008911 100644 --- a/stl/inc/compare +++ b/stl/inc/compare @@ -35,7 +35,7 @@ struct _Literal_zero { } } template , int> = 0> - _Literal_zero( _Ty ) = delete; + _Literal_zero(_Ty) = delete; }; using _Compare_t = signed char;