• Jason Rhinelander's avatar
    Use rvalue subcasting when casting an rvalue container · b57281bb
    Jason Rhinelander authored
    This updates the std::tuple, std::pair and `stl.h` type casters to
    forward their contained value according to whether the container being
    cast is an lvalue or rvalue reference.  This fixes an issue where
    subcaster casts were always called with a const lvalue which meant
    nested type casters didn't have the desired `cast()` overload invoked.
    For example, this caused Eigen values in a tuple to end up with a
    readonly flag (issue #935) and made it impossible to return a container
    of move-only types (issue #853).
    
    This fixes both issues by adding templated universal reference `cast()`
    methods to the various container types that forward container elements
    according to the container reference type.
    b57281bb
test_stl.cpp 7.85 KB