Revert noexcept deduction in favour of SFINAE lambda function matching #677
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.
noexcept
deduction, added in PR #555, doesn't work with clang's-std=c++1z
; and while it works with g++, it isn't entirely clear to me that it is required to work in C++17.What should work, however, is C++17's umplicit conversion of a
noexcept(true)
function pointer to anoexcept(false)
one (i.e. default,noexcept
-specifier-omitted). That was breaking in C++17 mode in pybind11 before #555 because thecpp_function
template used for lambdas provided a better match (i.e. without requiring an implicit conversion), but it then failed when trying to treat the matched function pointer as a lambda object.This commit takes a different approach of using SFINAE on the lambda function to prevent it from matching a non-lambda object, which then gets implicit conversion from a
noexcept
function pointer to anoexcept(false)
function pointer. This much nicer solution also gets rid of the C++17 NOEXCEPT macros, and works in both clang and g++.With this, pybind11 builds and tests successfully with clang 4.0 and libc++ 4.0 on linux under
-std=c++1z
.