catch2/tests/SelfTest/UsageTests
Martin Hořeňovský dc51386b9f
Support literal-zero detectors using consteval int constructors
This was originally motivated by `REQUIRE((a <=> b) == 0)` no
longer compiling using MSVC. After some investigation, I found
that they changed their implementation of the zero literal
detector from the previous pointer-constructor with deleted
other constructors, into one that uses `consteval` constructor
from int.

This breaks the previous detection logic, because now
`is_foo_comparable<std::strong_ordering, int>` is true, but
actually trying to compare them is a compile-time error...
The solution was to make the decomposition `constexpr` and rely
on a late C++20 DR that makes it so that `consteval` propagates
up through the callstack of `constexpr` functions, until it either
runs out of `constexpr` functions, or succeeds.

However, the default handling of types in decomposition is to
take a reference to them. This reference never becomes dangling,
but because the constexpr evaluation engine cannot prove this,
decomposition paths taking references to objects cannot be
actually evaluated at compilation time. Thankfully we already
did have a value-oriented decomposition path for arithmetic types
(as these are common linkage-less types), so we could just
explicitly spell out the `std::foo_ordering` types as also being
supposed to be decomposed by-value.

Two more fun facts about these changes
 1) The original motivation of the MSVC change was to avoid
    trigering a `Wzero-as-null-pointer-constant` warning. I still
    do not believe this was a good decision.
 2) Current latest version of MSVC does not actually implement the
    aforementioned C++20 DR, so even with this commit, MSVC cannot
    compile `REQUIRE((a <=> b) == 0)`.
2024-02-12 00:52:53 +01:00
..
Approx.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
BDD.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
Benchmark.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
Class.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
Compilation.tests.cpp Support literal-zero detectors using consteval int constructors 2024-02-12 00:52:53 +01:00
Condition.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
Decomposition.tests.cpp Add test for comparing pointers to NULL with != 2022-11-04 19:24:39 +01:00
EnumToString.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
Exception.tests.cpp Fix unreachable-code-return warnings 2023-04-20 14:53:03 +02:00
Generators.tests.cpp Add test showing literals and complex generators in one GENERATE 2023-12-10 18:32:45 +01:00
Matchers.tests.cpp Static analysis cleanup in tests 2023-05-29 21:45:30 +02:00
MatchersRanges.tests.cpp Fix spelling 2023-04-29 12:55:51 +02:00
Message.tests.cpp Fix tests for C++23's multi-arg index operator 2023-10-28 21:49:58 +02:00
Misc.tests.cpp Assert Info reset need to also reset result disposition to normal to handle uncaught exception correctly (#2723) 2023-08-07 22:07:31 +02:00
Skip.tests.cpp Test & document SKIP in generator constructor 2023-05-31 15:12:43 +02:00
ToStringByte.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringChrono.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringGeneral.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringOptional.tests.cpp implement stringify for std::nullopt_t 2023-08-30 16:21:02 +02:00
ToStringPair.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringTuple.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringVariant.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringVector.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
ToStringWhich.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
Tricky.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00
VariadicMacros.tests.cpp Fix references to license file 2022-10-28 11:30:15 +02:00