@@ -832,30 +832,6 @@ template <typename Container> struct is_copy_assignable<Container, enable_if_t<a
832
832
template <typename T1, typename T2> struct is_copy_assignable <std::pair<T1, T2>>
833
833
: all_of<is_copy_assignable<T1>, is_copy_assignable<T2>> {};
834
834
835
- // Helper for type_caster_base.
836
- struct make_constructor {
837
- using Constructor = void *(*)(const void *);
838
-
839
- /* Only enabled when the types are {copy,move}-constructible *and* when the type
840
- does not have a private operator new implementation. */
841
- template <typename T, typename = enable_if_t <is_copy_constructible<T>::value>>
842
- static auto make_copy_constructor (const T *x) -> decltype(new T(*x), Constructor{}) {
843
- return [](const void *arg) -> void * {
844
- return new T (*reinterpret_cast <const T *>(arg));
845
- };
846
- }
847
-
848
- template <typename T, typename = enable_if_t <std::is_move_constructible<T>::value>>
849
- static auto make_move_constructor (const T *x) -> decltype(new T(std::move(*const_cast <T *>(x))), Constructor{}) {
850
- return [](const void *arg) -> void * {
851
- return new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg))));
852
- };
853
- }
854
-
855
- static Constructor make_copy_constructor (...) { return nullptr ; }
856
- static Constructor make_move_constructor (...) { return nullptr ; }
857
- };
858
-
859
835
PYBIND11_NAMESPACE_END (detail)
860
836
861
837
// polymorphic_type_hook<itype>::get(src, tinfo) determines whether the object pointed
@@ -898,8 +874,7 @@ struct polymorphic_type_hook : public polymorphic_type_hook_base<itype> {};
898
874
PYBIND11_NAMESPACE_BEGIN (detail)
899
875
900
876
// / Generic type caster for objects stored on the heap
901
- template <typename type> class type_caster_base : public type_caster_generic,
902
- protected make_constructor {
877
+ template <typename type> class type_caster_base : public type_caster_generic {
903
878
using itype = intrinsic_t <type>;
904
879
905
880
public:
@@ -960,6 +935,28 @@ template <typename type> class type_caster_base : public type_caster_generic,
960
935
961
936
operator itype*() { return (type *) value; }
962
937
operator itype&() { if (!value) throw reference_cast_error (); return *((itype *) value); }
938
+
939
+ protected:
940
+ using Constructor = void *(*)(const void *);
941
+
942
+ /* Only enabled when the types are {copy,move}-constructible *and* when the type
943
+ does not have a private operator new implementation. */
944
+ template <typename T, typename = enable_if_t <is_copy_constructible<T>::value>>
945
+ static auto make_copy_constructor (const T *x) -> decltype (new T (*x), Constructor{}) {
946
+ return [](const void *arg) -> void * {
947
+ return new T (*reinterpret_cast <const T *>(arg));
948
+ };
949
+ }
950
+
951
+ template <typename T, typename = enable_if_t <std::is_move_constructible<T>::value>>
952
+ static auto make_move_constructor (const T *x) -> decltype (new T (std::move (*const_cast <T *>(x))), Constructor{}) {
953
+ return [](const void *arg) -> void * {
954
+ return new T (std::move (*const_cast <T *>(reinterpret_cast <const T *>(arg))));
955
+ };
956
+ }
957
+
958
+ static Constructor make_copy_constructor (...) { return nullptr ; }
959
+ static Constructor make_move_constructor (...) { return nullptr ; }
963
960
};
964
961
965
962
template <typename type, typename SFINAE = void > class type_caster : public type_caster_base <type> { };
0 commit comments