From 089328f77955685a29db9b9cf05e7c0893ee031b Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 6 Aug 2021 13:09:48 -0400 Subject: [PATCH] Revert "fix: apply simpler expression with fewer workarounds" This reverts commit 1fafd1b44796f39e56d4c029203c0e2ba18a60dd. --- include/pybind11/detail/type_caster_base.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index a708d87fb..e2d1bcb8c 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -927,17 +927,18 @@ protected: using Constructor = void *(*)(const void *); /* Only enabled when the types are {copy,move}-constructible *and* when the type - does not have a private operator new implementation. A comma operator is used in the decltype - argument to apply SFINAE to the public copy/move constructors.*/ + does not have a private operator new implementation. */ template ::value>> - static auto make_copy_constructor(const T *) -> decltype(new T(std::declval()), Constructor{}) { + static auto make_copy_constructor(const T *x) -> decltype(new T(*x), Constructor{}) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x); return [](const void *arg) -> void * { return new T(*reinterpret_cast(arg)); }; } template ::value>> - static auto make_move_constructor(const T *) -> decltype(new T(std::declval()), Constructor{}) { + static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast(x))), Constructor{}) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x); return [](const void *arg) -> void * { return new T(std::move(*const_cast(reinterpret_cast(arg)))); };