Skip to content

Commit 4063a9d

Browse files
committed
Fixing tests
1 parent 370f397 commit 4063a9d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

tests/test-app/extra_type_traits_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ TEST_CASE("is_equal_comparable", "[extra_type_traits]") {
2828
static_assert (is_equal_comparable_v<comparable, comparable>);
2929
static_assert (!is_equal_comparable_v<non_comparable, non_comparable>);
3030
static_assert (is_equal_comparable_v<comparable, int>);
31-
#if __cplusplus > 201703L && (!defined __GNUC__ || __GNUC__ >= 10)
31+
// C++20 rewritten candidates make 'int == comparable' valid via comparable::operator==(int). Clang defines
32+
// __GNUC__ as 4 yet supports this, so gate it in explicitly, alongside GCC>=10 and MSVC (which defines neither).
33+
#if __cplusplus > 201703L && (defined __clang__ || !defined __GNUC__ || __GNUC__ >= 10)
3234
static_assert (is_equal_comparable_v<int, comparable>);
3335
#else
3436
static_assert (!is_equal_comparable_v<int, comparable>);

utility/constexpr_algorithms.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ namespace detail {
1212
{
1313
if constexpr (std::is_same_v<bool, decltype(f.template operator()<First>())>)
1414
{
15-
constexpr bool proceed = f.template operator()<First>();
15+
// 'f' is a function parameter, not a constant expression: calling it here is non-portable (Apple
16+
// Clang rejects f.operator()<First>() in this constexpr context). A captureless closure is
17+
// default-constructible in C++20, so a fresh value-initialized one gives a genuine constant.
18+
constexpr bool proceed = decltype(f){}.template operator()<First>();
1619
if constexpr (proceed)
1720
consteval_for_T<T, First + 1, Last>(f);
1821
}

0 commit comments

Comments
 (0)