File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -644,6 +644,10 @@ struct copyable_holder_caster : public type_caster_base<type> {
644
644
// static_cast works around compiler error with MSVC 17 and CUDA 10.2
645
645
// see issue #2180
646
646
explicit operator type&() { return *(static_cast <type *>(this ->value )); }
647
+
648
+ // holders only support copying, not moving
649
+ template <typename T> using cast_op_type = detail::cast_op_type<T>;
650
+
647
651
explicit operator holder_type*() { return std::addressof (holder); }
648
652
explicit operator holder_type&() { return holder; }
649
653
Original file line number Diff line number Diff line change @@ -912,10 +912,12 @@ template <typename type> class type_caster_base : public type_caster_generic {
912
912
nullptr , nullptr , holder);
913
913
}
914
914
915
- template <typename T> using cast_op_type = detail::cast_op_type<T>;
915
+ // allow moving of custom types
916
+ template <typename T> using cast_op_type = detail::movable_cast_op_type<T>;
916
917
917
918
operator itype*() { return (type *) value; }
918
919
operator itype&() { if (!value) throw reference_cast_error (); return *((itype *) value); }
920
+ operator itype&&() && { if (!value) throw reference_cast_error (); return std::move (*((itype *) value)); }
919
921
920
922
protected:
921
923
using Constructor = void *(*)(const void *);
You can’t perform that action at this time.
0 commit comments