• Wenzel Jakob's avatar
    stl.h: propagate return value policies to type-specific casters (#1455) · cbd16a82
    Wenzel Jakob authored
    * stl.h: propagate return value policies to type-specific casters
    
    Return value policies for containers like those handled in in 'stl.h'
    are currently broken.
    
    The problem is that detail::return_value_policy_override<C>::policy()
    always returns 'move' when given a non-pointer/reference type, e.g.
    'std::vector<...>'.
    
    This is sensible behavior for custom types that are exposed via
    'py::class_<>', but it does not make sense for types that are handled by
    other type casters (STL containers, Eigen matrices, etc.).
    
    This commit changes the behavior so that
    detail::return_value_policy_override only becomes active when the type
    caster derives from type_caster_generic.
    
    Furthermore, the override logic is called recursively in STL type
    casters to enable key/value-specific behavior.
    cbd16a82
test_stl.cpp 9.96 KB