Library of Assembled Shared Sources
|
Helper class to create PyExportTraits for NoNone wrapped types. More...
#include <export_traits.h>
Static Public Member Functions | |
static PyObject * | build (const NoNone< T > &value) |
Raise a Python TypeError if value is equal to nullptr | |
static int | get (PyObject *obj, NoNone< T > &value) |
Raise a Python TypeError if obj is equal to None | |
Helper class to create PyExportTraits for NoNone wrapped types.
NoNone wrapped types are used to ensure that:
None
values can be passed from Python to C++ (which would be translated to a nullptr
),nullptr
values can be returned to Python (which would be translated to a None
).Use this helper to create PyExportTraits for your own NoNone wrapped types by inheriting from it.
Built-in specializations are provided for raw pointers T*
, util::SharedPtr<T>, and std::shared_ptr<T>
.
typename T
as the main template parameter for your actual type, then the Python type will automatically be deduced. If not, or if you still see a T | None
type-hint, you can can override the py_typing
member to specify the type-hint you want.Definition at line 595 of file export_traits.h.