Commit acedd6c7 authored by Jason Rhinelander's avatar Jason Rhinelander
Browse files

std::reference_wrapper: non-generic types; no None

This reimplements the std::reference_wrapper<T> caster to be a shell
around the underlying T caster (rather than assuming T is a generic
type), which lets it work for things like `std::reference_wrapper<int>`
or anything else custom type caster with a lvalue cast operator.

This also makes it properly fail when None is provided, just as an
ordinary lvalue reference argument would similarly fail.

This also adds a static assert to test that T has an appropriate type
caster.  It triggers for casters like `std::pair`, which have
return-by-value cast operators.  (In theory this could be supported by
storing a local temporary for such types, but that's beyond the scope
of this PR).

This also replaces `automatic` or `take_ownership` return value policies
with `automatic_reference` as taking ownership of a reference inside a
reference_wrapper is not valid.
parent 7cdf9f1a
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment