@@ -824,30 +824,6 @@ template <typename Container> struct is_copy_assignable<Container, enable_if_t<a
824
824
template <typename T1, typename T2> struct is_copy_assignable <std::pair<T1, T2>>
825
825
: all_of<is_copy_assignable<T1>, is_copy_assignable<T2>> {};
826
826
827
- // Helper for type_caster_base.
828
- struct make_constructor {
829
- using Constructor = void *(*)(const void *);
830
-
831
- /* Only enabled when the types are {copy,move}-constructible *and* when the type
832
- does not have a private operator new implementation. */
833
- template <typename T, typename = enable_if_t <is_copy_constructible<T>::value>>
834
- static auto make_copy_constructor (const T *x) -> decltype(new T(*x), Constructor{}) {
835
- return [](const void *arg) -> void * {
836
- return new T (*reinterpret_cast <const T *>(arg));
837
- };
838
- }
839
-
840
- template <typename T, typename = enable_if_t <std::is_move_constructible<T>::value>>
841
- static auto make_move_constructor (const T *x) -> decltype(new T(std::move(*const_cast <T *>(x))), Constructor{}) {
842
- return [](const void *arg) -> void * {
843
- return new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg))));
844
- };
845
- }
846
-
847
- static Constructor make_copy_constructor (...) { return nullptr ; }
848
- static Constructor make_move_constructor (...) { return nullptr ; }
849
- };
850
-
851
827
PYBIND11_NAMESPACE_END (detail)
852
828
853
829
// polymorphic_type_hook<itype>::get(src, tinfo) determines whether the object pointed
@@ -890,8 +866,7 @@ struct polymorphic_type_hook : public polymorphic_type_hook_base<itype> {};
890
866
PYBIND11_NAMESPACE_BEGIN (detail)
891
867
892
868
// / Generic type caster for objects stored on the heap
893
- template <typename type> class type_caster_base : public type_caster_generic,
894
- protected make_constructor {
869
+ template <typename type> class type_caster_base : public type_caster_generic {
895
870
using itype = intrinsic_t <type>;
896
871
897
872
public:
@@ -952,6 +927,28 @@ template <typename type> class type_caster_base : public type_caster_generic,
952
927
953
928
operator itype*() { return (type *) value; }
954
929
operator itype&() { if (!value) throw reference_cast_error (); return *((itype *) value); }
930
+
931
+ protected:
932
+ using Constructor = void *(*)(const void *);
933
+
934
+ /* Only enabled when the types are {copy,move}-constructible *and* when the type
935
+ does not have a private operator new implementation. */
936
+ template <typename T, typename = enable_if_t <is_copy_constructible<T>::value>>
937
+ static auto make_copy_constructor (const T *x) -> decltype (new T (*x), Constructor{}) {
938
+ return [](const void *arg) -> void * {
939
+ return new T (*reinterpret_cast <const T *>(arg));
940
+ };
941
+ }
942
+
943
+ template <typename T, typename = enable_if_t <std::is_move_constructible<T>::value>>
944
+ static auto make_move_constructor (const T *x) -> decltype (new T (std::move (*const_cast <T *>(x))), Constructor{}) {
945
+ return [](const void *arg) -> void * {
946
+ return new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg))));
947
+ };
948
+ }
949
+
950
+ static Constructor make_copy_constructor (...) { return nullptr ; }
951
+ static Constructor make_move_constructor (...) { return nullptr ; }
955
952
};
956
953
957
954
template <typename type, typename SFINAE = void > class type_caster : public type_caster_base <type> { };
0 commit comments