From 2d965d43a673d48fdce7bf1771f96a009e1e018a Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sun, 12 Mar 2017 13:34:30 -0300 Subject: [PATCH] Add MSVC 2017 cpp_function ICE workaround The `decltype(...)` in the template parameter that gives us SFINAE matching for a lambda makes MSVC 2017 ICE; this works around if by changing the test to an explicit not-a-function-or-pointer test, which seems to work everywhere. --- include/pybind11/pybind11.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 44c4b61c..8cccd4c3 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -51,9 +51,14 @@ public: } /// Construct a cpp_function from a lambda function (possibly with internal state) - template ::type::operator())>::type> + template ::type, + std::is_function, std::is_pointer, std::is_member_pointer + >::value> + > cpp_function(Func &&f, const Extra&... extra) { + using FuncType = typename detail::remove_class::type::operator())>::type; initialize(std::forward(f), (FuncType *) nullptr, extra...); }