81template <op_
id, op_type,
typename B,
typename L,
typename R>
85template <op_
id id, op_type ot,
typename L,
typename R>
87 template <
typename Class,
typename... Extra>
88 void execute(Class &cl,
const Extra &...extra)
const {
89 using Base =
typename Class::type;
93 cl.def(op::name(), &op::execute,
is_operator(), extra...);
94#if PY_MAJOR_VERSION < 3
98 : ot ==
op_l ?
"__div__"
105 template <
typename Class,
typename... Extra>
107 using Base =
typename Class::type;
111 cl.def(op::name(), &op::execute_cast,
is_operator(), extra...);
112#if PY_MAJOR_VERSION < 3
115 : ot ==
op_l ?
"__div__"
124#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr) \
125 template <typename B, typename L, typename R> \
126 struct op_impl<op_##id, op_l, B, L, R> { \
127 static char const *name() { return "__" #id "__"; } \
128 static auto execute(const L &l, const R &r) -> decltype(expr) { return (expr); } \
129 static B execute_cast(const L &l, const R &r) { return B(expr); } \
131 template <typename B, typename L, typename R> \
132 struct op_impl<op_##id, op_r, B, L, R> { \
133 static char const *name() { return "__" #rid "__"; } \
134 static auto execute(const R &r, const L &l) -> decltype(expr) { return (expr); } \
135 static B execute_cast(const R &r, const L &l) { return B(expr); } \
137 inline op_<op_##id, op_l, self_t, self_t> op(const self_t &, const self_t &) { \
138 return op_<op_##id, op_l, self_t, self_t>(); \
140 template <typename T> \
141 op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \
142 return op_<op_##id, op_l, self_t, T>(); \
144 template <typename T> \
145 op_<op_##id, op_r, T, self_t> op(const T &, const self_t &) { \
146 return op_<op_##id, op_r, T, self_t>(); \
149#define PYBIND11_INPLACE_OPERATOR(id, op, expr) \
150 template <typename B, typename L, typename R> \
151 struct op_impl<op_##id, op_l, B, L, R> { \
152 static char const *name() { return "__" #id "__"; } \
153 static auto execute(L &l, const R &r) -> decltype(expr) { return expr; } \
154 static B execute_cast(L &l, const R &r) { return B(expr); } \
156 template <typename T> \
157 op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \
158 return op_<op_##id, op_l, self_t, T>(); \
161#define PYBIND11_UNARY_OPERATOR(id, op, expr) \
162 template <typename B, typename L> \
163 struct op_impl<op_##id, op_u, B, L, undefined_t> { \
164 static char const *name() { return "__" #id "__"; } \
165 static auto execute(const L &l) -> decltype(expr) { return expr; } \
166 static B execute_cast(const L &l) { return B(expr); } \
168 inline op_<op_##id, op_u, self_t, undefined_t> op(const self_t &) { \
169 return op_<op_##id, op_u, self_t, undefined_t>(); \
211#undef PYBIND11_BINARY_OPERATOR
212#undef PYBIND11_INPLACE_OPERATOR
213#undef PYBIND11_UNARY_OPERATOR
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE_BEGIN(name)
typename std::conditional< B, T, F >::type conditional_t
#define PYBIND11_SILENCE_MSVC_C4127(...)
#define PYBIND11_INPLACE_OPERATOR(id, op, expr)
#define PYBIND11_UNARY_OPERATOR(id, op, expr)
#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr)
op_id
Enumeration with all supported operator types.
self_t __self()
Don't warn about an unused variable.
std::string abs(const Vector2 &)
Annotation for operators.
Operator implementation generator.
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.