|
Library of Assembled Shared Sources
|
Wrapper to prevent None values being passed to and from Python.
More...
#include <no_none.h>

Public Member Functions | |
| T & | reference () |
| Return reference to wrapped value. | |
| const T & | reference () const |
| Return reference to wrapped value. | |
Wrapper to prevent None values being passed to and from Python.
Use this class to wrap a value of type T that could be None in Python (for example, a pointer type), but you want to ensure that the value is always valid and not None.
Works in both directions: from and to Python. In case a None value is passed or returned, it will raise a Python TypeError instead.
None values from crossing the Python/C++ boundary. It does NOT provide any other runtime or compile-time checks. You can happily put a nullptr in a NoNone<T> as long as you don't pass it to Python.Built-in support for NoNone is provided for raw pointers T*, util::SharedPtr<T>, and std::shared_ptr<T>. To support your own types, you must specialize PyExportTraits: see PyExportTraitsNoNone for more information.