From 25fd2c79e9ce995507b1b8594ef795bf55a2f0fd Mon Sep 17 00:00:00 2001 From: Samuel Freilich Date: Tue, 17 Jun 2025 13:58:07 -0400 Subject: [PATCH] Exclude tests returning `std::optional` from TestReturnsOrderingOrSearchGuide Since those are matched by an overload enabled on TestReturnsOptionalOrderingOrSearchGuide, matching both results in `error: call to 'BinarySearch' is ambiguous`. Though I suspect both shouldn't be matched anyways, since I'm only seeing this under a build using `clang-cl` on Windows, not clang on Linux (both using C++20). Also replace `decltype(std::declval()(std::declval()))` with the much clearer `std::invoke_result_t`, since the code already requires C++17. --- .gitignore | 2 ++ riegeli/base/binary_search.h | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b982aab2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +MODULE.bazel.lock +bazel-* diff --git a/riegeli/base/binary_search.h b/riegeli/base/binary_search.h index d1ae524e..406479dc 100644 --- a/riegeli/base/binary_search.h +++ b/riegeli/base/binary_search.h @@ -150,8 +150,11 @@ struct TestReturnsOrderingOrSearchGuide : std::false_type {}; template struct TestReturnsOrderingOrSearchGuide< Test, Pos, - std::enable_if_t()(std::declval())), Pos>::value>> + std::enable_if_t, Pos>, + std::negation, Pos>>>>> : std::true_type {}; template @@ -161,7 +164,7 @@ template struct TestReturnsOptionalOrderingOrSearchGuide< Test, Pos, std::enable_if_t()(std::declval())), Pos>::value>> + std::invoke_result_t, Pos>::value>> : std::true_type {}; template @@ -171,7 +174,7 @@ template struct TestReturnsStatusOrOrderingOrSearchGuide< Test, Pos, std::enable_if_t()(std::declval())), Pos>::value>> + std::invoke_result_t, Pos>::value>> : std::true_type {}; } // namespace binary_search_internal