Library of Assembled Shared Sources
lass::python::PyExportTraitsNoNone< T > Struct Template Reference

Helper class to create PyExportTraits for NoNone wrapped types. More...

#include <export_traits.h>

Inheritance diagram for lass::python::PyExportTraitsNoNone< T >:

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
 

Detailed Description

template<typename T>
struct lass::python::PyExportTraitsNoNone< T >

Helper class to create PyExportTraits for NoNone wrapped types.

NoNone wrapped types are used to ensure that:

  • No None values can be passed from Python to C++ (which would be translated to a nullptr),
  • No 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.

template <typename T, template <typename, typename> class S, typename C>
struct PyExportTraits< NoNone< util::SharedPtr<T, S, C> > >: public PyExportTraitsNoNone< util::SharedPtr<T, S, C> >
{
constexpr static const char* py_typing = "T"; // optional
};
Wrapper to prevent None values being passed to and from Python.
Definition no_none.h:84
general utility, debug facilities, ...
Helper class to create PyExportTraits for NoNone wrapped types.
by copy, general case assumes shadow type or PyObjectPlus based type.

Built-in specializations are provided for raw pointers T*, util::SharedPtr<T>, and std::shared_ptr<T>.

Note
If you use 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.
See also
NoNone
PyExportTraits<NoNone<T*>>
PyExportTraits<NoNone<util::SharedPtr<T,S,C>>>
PyExportTraits<NoNone<std::shared_ptr<T>>>

Definition at line 595 of file export_traits.h.


The documentation for this struct was generated from the following file: