81template <op_
id, op_type,
typename B,
typename L,
typename R>
85template <op_
id id, op_type ot,
typename L,
typename R>
88 template <
typename Class,
typename... Extra>
89 void execute(Class &cl,
const Extra &...extra)
const {
90 using Base =
typename Class::type;
94 cl.def(op::name(), &op::execute,
is_operator(), extra...);
96 template <
typename Class,
typename... Extra>
98 using Base =
typename Class::type;
102 cl.def(op::name(), &op::execute_cast,
is_operator(), extra...);
106#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr) \
107 template <typename B, typename L, typename R> \
108 struct op_impl<op_##id, op_l, B, L, R> { \
109 static char const *name() { return "__" #id "__"; } \
110 static auto execute(const L &l, const R &r) -> decltype(expr) { return (expr); } \
111 static B execute_cast(const L &l, const R &r) { return B(expr); } \
113 template <typename B, typename L, typename R> \
114 struct op_impl<op_##id, op_r, B, L, R> { \
115 static char const *name() { return "__" #rid "__"; } \
116 static auto execute(const R &r, const L &l) -> decltype(expr) { return (expr); } \
117 static B execute_cast(const R &r, const L &l) { return B(expr); } \
119 inline op_<op_##id, op_l, self_t, self_t> op(const self_t &, const self_t &) { \
120 return op_<op_##id, op_l, self_t, self_t>(); \
122 template <typename T> \
123 op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \
124 return op_<op_##id, op_l, self_t, T>(); \
126 template <typename T> \
127 op_<op_##id, op_r, T, self_t> op(const T &, const self_t &) { \
128 return op_<op_##id, op_r, T, self_t>(); \
131#define PYBIND11_INPLACE_OPERATOR(id, op, expr) \
132 template <typename B, typename L, typename R> \
133 struct op_impl<op_##id, op_l, B, L, R> { \
134 static char const *name() { return "__" #id "__"; } \
135 static auto execute(L &l, const R &r) -> decltype(expr) { return expr; } \
136 static B execute_cast(L &l, const R &r) { return B(expr); } \
138 template <typename T> \
139 op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \
140 return op_<op_##id, op_l, self_t, T>(); \
143#define PYBIND11_UNARY_OPERATOR(id, op, expr) \
144 template <typename B, typename L> \
145 struct op_impl<op_##id, op_u, B, L, undefined_t> { \
146 static char const *name() { return "__" #id "__"; } \
147 static auto execute(const L &l) -> decltype(expr) { return expr; } \
148 static B execute_cast(const L &l) { return B(expr); } \
150 inline op_<op_##id, op_u, self_t, undefined_t> op(const self_t &) { \
151 return op_<op_##id, op_u, self_t, undefined_t>(); \
193#undef PYBIND11_BINARY_OPERATOR
194#undef PYBIND11_INPLACE_OPERATOR
195#undef PYBIND11_UNARY_OPERATOR
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE_BEGIN(name)
typename std::conditional< B, T, F >::type conditional_t
op_id
Enumeration with all supported operator types.
std::string abs(const Vector2 &)
#define PYBIND11_INPLACE_OPERATOR(id, op, expr)
#define PYBIND11_UNARY_OPERATOR(id, op, expr)
#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr)
self_t __self()
Don't warn about an unused variable.
Annotation for operators.
Operator implementation generator.
static constexpr bool op_enable_if_hook
void execute(Class &cl, const Extra &...extra) const
void execute_cast(Class &cl, const Extra &...extra) const
base template of operator implementations
Type for an unused type slot.