@@ -927,20 +927,17 @@ template <typename type> class type_caster_base : public type_caster_generic {
927
927
using Constructor = void *(*)(const void *);
928
928
929
929
/* Only enabled when the types are {copy,move}-constructible *and* when the type
930
- does not have a private operator new implementation. */
930
+ does not have a private operator new implementation. A comma operator is used in the decltype
931
+ argument to apply SFINAE to the public copy/move constructors.*/
931
932
template <typename T, typename = enable_if_t <is_copy_constructible<T>::value>>
932
- static auto make_copy_constructor (const T *x) -> decltype (new T (*x), Constructor{}) {
933
- PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100 (x);
934
- PYBIND11_WORKAROUND_INCORRECT_OLD_GCC_UNUSED_BUT_SET_PARAMETER (x);
933
+ static auto make_copy_constructor (const T *) -> decltype (new T (std::declval<const T>()), Constructor{}) {
935
934
return [](const void *arg) -> void * {
936
935
return new T (*reinterpret_cast <const T *>(arg));
937
936
};
938
937
}
939
938
940
939
template <typename T, typename = enable_if_t <std::is_move_constructible<T>::value>>
941
- static auto make_move_constructor (const T *x) -> decltype (new T (std::move (*const_cast <T *>(x))), Constructor{}) {
942
- PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100 (x);
943
- PYBIND11_WORKAROUND_INCORRECT_OLD_GCC_UNUSED_BUT_SET_PARAMETER (x);
940
+ static auto make_move_constructor (const T *) -> decltype (new T (std::declval<T&&>()), Constructor{}) {
944
941
return [](const void *arg) -> void * {
945
942
return new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg))));
946
943
};
0 commit comments