@@ -774,13 +774,23 @@ template <typename type> class type_caster_base : public type_caster_generic {
774
774
operator itype&() { if (!value) throw reference_cast_error (); return *((itype *) value); }
775
775
776
776
protected:
777
- typedef void *(*Constructor)(const void *stream);
777
+ using Constructor = void *(*)(const void *);
778
+
778
779
/* Only enabled when the types are {copy,move}-constructible *and* when the type
779
- does not have a private operator new implementaton. */
780
- template <typename T = type, typename = enable_if_t <is_copy_constructible<T>::value>> static auto make_copy_constructor (const T *value) -> decltype(new T(*value), Constructor(nullptr )) {
781
- return [](const void *arg) -> void * { return new T (*((const T *) arg)); }; }
782
- template <typename T = type> static auto make_move_constructor (const T *value) -> decltype(new T(std::move(*((T *) value))), Constructor(nullptr )) {
783
- return [](const void *arg) -> void * { return (void *) new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg)))); }; }
780
+ does not have a private operator new implementation. */
781
+ template <typename T, typename = enable_if_t <is_copy_constructible<T>::value>>
782
+ static auto make_copy_constructor (const T *x) -> decltype(new T(*x), Constructor{}) {
783
+ return [](const void *arg) -> void * {
784
+ return new T (*reinterpret_cast <const T *>(arg));
785
+ };
786
+ }
787
+
788
+ template <typename T, typename = enable_if_t <std::is_move_constructible<T>::value>>
789
+ static auto make_move_constructor (const T *x) -> decltype(new T(std::move(*(T *) x)), Constructor{}) {
790
+ return [](const void *arg) -> void * {
791
+ return new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg))));
792
+ };
793
+ }
784
794
785
795
static Constructor make_copy_constructor (...) { return nullptr ; }
786
796
static Constructor make_move_constructor (...) { return nullptr ; }
0 commit comments