pybind11/docs/advanced
Dean Moldovan 03f627ebb1 Make reference(_internal) the default return value policy for properties (#473)
* Make reference(_internal) the default return value policy for properties

Before this, all `def_property*` functions used `automatic` as their
default return value policy. This commit makes it so that:

 * Non-static properties use `reference_interal` by default, thus
   matching `def_readonly` and `def_readwrite`.

 * Static properties use `reference` by default, thus matching
   `def_readonly_static` and `def_readwrite_static`.

In case `cpp_function` is passed to any `def_property*`, its policy will
be used instead of any defaults. User-defined arguments in `extras`
still have top priority and will override both the default policies and
the ones from `cpp_function`.

Resolves #436.

* Almost always use return_value_policy::move for rvalues

For functions which return rvalues or rvalue references, the only viable
return value policies are `copy` and `move`. `reference(_internal)` and
`take_ownership` would take the address of a temporary which is always
an error.

This commit prevents possible user errors by overriding the bad rvalue
policies with `move`. Besides `move`, only `copy` is allowed, and only
if it's explicitly selected by the user.

This is also a necessary safety feature to support the new default
return value policies for properties: `reference(_internal)`.
2016-11-01 11:44:57 +01:00
..
cast a bit of work on the new documentation structure 2016-10-24 23:48:20 +02:00
pycpp Reorganize documentation 2016-10-20 15:21:34 +02:00
classes.rst Reorganize documentation 2016-10-20 15:21:34 +02:00
exceptions.rst Reorganize documentation 2016-10-20 15:21:34 +02:00
functions.rst Make reference(_internal) the default return value policy for properties (#473) 2016-11-01 11:44:57 +01:00
misc.rst Reorganize documentation 2016-10-20 15:21:34 +02:00
smart_ptrs.rst Support std::shared_ptr holder type out of the box 2016-10-20 16:19:58 +02:00