Repository navigation
fix utki::assert() ambiguity for lambdas in Objective-C++ - #33
Closed
igagis-bot wants to merge 2 commits into
Closed
igagis-bot wants to merge 2 commits into
igagis-bot wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
=======================================
Coverage 84.86% 84.86%
=======================================
Files 31 31
Lines 1559 1559
Branches 384 402 +18
=======================================
Hits 1323 1323
Misses 174 174
Partials 62 62 ☔ View full report in Codecov by Harness. |
igagis-bot
force-pushed
the
fix/objcpp-assert-ambiguity
branch
from
November 23, 2026 01:48
16fc05a to
32dcca5
Compare
igagis-bot
force-pushed
the
fix/objcpp-assert-ambiguity
branch
from
November 23, 2026 01:59
32dcca5 to
c716402
Compare
This was referenced Nov 23, 2026
In Objective-C++ code (built with -fblocks), lambda closure types are
implicitly convertible to bool. This made calls of the form
utki::assert([]() { return true; });
ambiguous: both the bool overload and the condition_checker
(std::function<bool()>) overload were viable candidates.
Convert the bool-taking overloads to templates constrained with SFINAE
to exactly the bool type, so that they are only selected for actual
bool arguments and lambdas keep binding to the condition_checker
overload unambiguously.
igagis-bot
force-pushed
the
fix/objcpp-assert-ambiguity
branch
from
November 23, 2026 02:07
c716402 to
7b98804
Compare
the previous constraint (is_same_v<decay_t<T>, bool>) rejected scalar
condition types other than bool (int, size_t, Win32 BOOL, ...), which
used to convert implicitly to the bool parameter. this broke the windows
build of ruisapp, where e.g. UnregisterClassW() returns BOOL:
error C2665: 'utki::assert': no overloaded function could convert
all the argument types
the new constraint (!is_class_v<decay_t<T>>) accepts every scalar type
while still excluding class types (lambdas, smart pointers,
std::function), which have dedicated overloads. this also keeps the
objective-c++ fix: in objective-c++ with -fblocks lambdas are
implicitly convertible to bool (via a block pointer), and with the old
non-template bool overload a lambda condition was ambiguous with the
condition_checker overload.
Member
|
there seem to be no such problem in pure C++. what if you change the lambda to &{...} in objective-C++ code? |
Contributor
Author
|
Superseded by #34. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Objective-C++ code (built with -fblocks), lambda closure types are implicitly convertible to bool. This made calls of the form
ambiguous: both the
booloverload and thecondition_checker(std::function<bool()>) overload were viable candidates, breaking the iOS build.Converts the bool-taking overloads to templates constrained with SFINAE to exactly the
booltype, so that they are only selected for actual bool arguments and lambdas keep binding to thecondition_checkeroverload unambiguously.