Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

ResultConverter

Introduction
ResultConverter Concept Requirements
ResultConverterGenerator Concept Requirements

A ResultConverter for a type T is a type whose instances can be used to convert C++ return values of type T to_python. A ResultConverterGenerator is an MPL unary metafunction class which, given the return type of a C++ function, returns a ResultConverter for that type. ResultConverters in Boost.Python generally inspect library's registry of converters to find a suitable converter, but converters which don't use the registry are also possible.

In the table below, C denotes a ResultConverter type for a type R, c denotes an object of type C, and r denotes an object of type R.

Expression

Type

Semantics

C c

Constructs a c object.

c.convertible()

convertible to bool

false iff no conversion from any R value to a Python object is possible.

c(r)

convertible to PyObject*

A pointer to a Python object corresponding to r, or 0 iff r could not be converted to_python, in which case PyErr_Occurred should return non-zero.

c.get_pytype()

PyTypeObject const *

A pointer to a Python Type object corresponding to result of the conversion, or 0. Used for documentation generation. If 0 is returned the generated type in the documentation will be object.

In the table below, G denotes a ResultConverterGenerator type and R denotes a possible C++ function return type.

Expression

Requirements

G::apply<R>::type

A ResultConverter type for R.


PrevUpHomeNext