@@ -45,25 +45,27 @@ template <op_id id, op_type ot, typename L, typename R> struct op_ {
4545 using Lt = std::conditional_t <std::is_same_v<L, self_t >, Type, L>;
4646 using Rt = std::conditional_t <std::is_same_v<R, self_t >, Type, R>;
4747 using Op = op_impl<id, ot, Type, Lt, Rt>;
48- cl.def (Op::name (), &Op::execute, is_operator (), extra...);
48+ cl.def (Op::name (), &Op::execute, is_operator (), Op::default_policy, extra...);
4949 }
5050
5151 template <typename Class, typename ... Extra> void execute_cast (Class &cl, const Extra&... extra) const {
5252 using Type = typename Class::Type;
5353 using Lt = std::conditional_t <std::is_same_v<L, self_t >, Type, L>;
5454 using Rt = std::conditional_t <std::is_same_v<R, self_t >, Type, R>;
5555 using Op = op_impl<id, ot, Type, Lt, Rt>;
56- cl.def (Op::name (), &Op::execute_cast, is_operator (), extra...);
56+ cl.def (Op::name (), &Op::execute_cast, is_operator (), Op::default_policy, extra...);
5757 }
5858};
5959
6060#define NB_BINARY_OPERATOR (id, rid, op, expr ) \
6161template <typename B, typename L, typename R> struct op_impl <op_##id, op_l, B, L, R> { \
62+ static constexpr rv_policy default_policy = rv_policy::automatic; \
6263 static char const * name () { return " __" #id " __" ; } \
6364 static auto execute (const L &l, const R &r) -> decltype(expr) { return (expr); } \
6465 static B execute_cast (const L &l, const R &r) { return B (expr); } \
6566}; \
6667template <typename B, typename L, typename R> struct op_impl <op_##id, op_r, B, L, R> { \
68+ static constexpr rv_policy default_policy = rv_policy::automatic; \
6769 static char const * name () { return " __" #rid " __" ; } \
6870 static auto execute (const R &r, const L &l) -> decltype(expr) { return (expr); } \
6971 static B execute_cast (const R &r, const L &l) { return B (expr); } \
@@ -80,6 +82,7 @@ template <typename T> op_<op_##id, op_r, T, self_t> op(const T &, const self_t &
8082
8183#define NB_INPLACE_OPERATOR (id, op, expr ) \
8284template <typename B, typename L, typename R> struct op_impl <op_##id, op_l, B, L, R> { \
85+ static constexpr rv_policy default_policy = rv_policy::move; \
8386 static char const * name () { return " __" #id " __" ; } \
8487 static auto execute (L &l, const R &r) -> decltype(expr) { return expr; } \
8588 static B execute_cast (L &l, const R &r) { return B (expr); } \
@@ -90,6 +93,7 @@ template <typename T> op_<op_##id, op_l, self_t, T> op(const self_t &, const T &
9093
9194#define NB_UNARY_OPERATOR (id, op, expr ) \
9295template <typename B, typename L> struct op_impl <op_##id, op_u, B, L, undefined_t > { \
96+ static constexpr rv_policy default_policy = rv_policy::automatic; \
9397 static char const * name () { return " __" #id " __" ; } \
9498 static auto execute (const L &l) -> decltype(expr) { return expr; } \
9599 static B execute_cast (const L &l) { return B (expr); } \
0 commit comments