Skip to content

Commit 4c7ff46

Browse files
committed
Trying a workaround for the clang bug
1 parent 4063a9d commit 4c7ff46

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

tests/test-app/constexpr_algos_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ TEST_CASE("consteval_for - compile-time operation", "[constexpr-algos]")
210210

211211
TEST_CASE("consteval_for -> bool - early exit at runtime", "[constexpr-algos]")
212212
{
213-
consteval_for<5, 200>([]<auto index>() -> bool {
213+
consteval_for<5, 200>([]<auto index>() consteval -> bool {
214214
static_assert(std::is_same_v<decltype(index), size_t>);
215215
static_assert (index >= 5 && index <= 7);
216216

utility/constexpr_algorithms.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ namespace detail {
1212
{
1313
if constexpr (std::is_same_v<bool, decltype(f.template operator()<First>())>)
1414
{
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>();
15+
constexpr bool proceed = f.template operator()<First>();
1916
if constexpr (proceed)
2017
consteval_for_T<T, First + 1, Last>(f);
2118
}

0 commit comments

Comments
 (0)