You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Differentiate between copying and moving of custom types based on the function signature
So far, using the movable_cast_op_type, always enabled move semantics,
even when copy semantics would be expected from the function signature.
While C++ decides about copy vs move semantics based on the type of the passed argument,
Python doesn't know about lvalue and rvalue references and thus cannot decide based on the
passed argument. Instead, the wrapper needs to explicitly define the desired semantics of
argument passing as follows:
- f(T&) passes an lvalue reference
- f(T&&) passes an rvalue reference
- f(T) passes an lvalue reference by default (triggering copy construction)
but falls back to an rvalue reference if copying is not supported (thus triggering move construction)
This commit essentially makes call_impl() pass the argument casters to cast_op() by lvalue references, thus
enabling the distinction between copy and move semantics based on the argument's type.
0 commit comments