Skip to content

Commit

Permalink
Allows non-copy-constructible T in SharedPtr<T>.
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-caldas committed Oct 23, 2024
1 parent 65889ab commit 4a46e17
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/python_bindings/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,19 @@
#include <base/expected_behaviour/SharedPtr.h>
#include <base/naming_scheme/Uuid.h>

PYBIND11_DECLARE_HOLDER_TYPE(T, PYBIND11_TYPE(SharedPtr<T,T>));
PYBIND11_MAKE_OPAQUE(NamingScheme::Uuid::uuid_type);

/*
* A SharedPtr<T> is copy constructible even if T is not!
* So, PYBIND11_DECLARE_HOLDER_TYPE does not work. :-(
*/
//PYBIND11_DECLARE_HOLDER_TYPE(T, SharedPtr<T>);
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
namespace detail {
template <typename T>
class type_caster<SharedPtr<T>>
: public copyable_holder_caster<T, SharedPtr<T>> {};
template <typename T>
struct is_holder_type<T, SharedPtr<T>> : std::true_type {};
}
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

0 comments on commit 4a46e17

Please sign in to comment.