42 return "[" + std::to_string(
x) +
", " + std::to_string(
y) +
"]";
127 return std::hash<std::string>()(selector.
member);
136 #if !defined(_MSC_VER) && !defined(__INTEL_COMPILER) 137 # pragma GCC diagnostic push 143 # if defined(__APPLE__) && defined(__clang__) 144 # if (__clang_major__ >= 10) 145 # pragma GCC diagnostic ignored "-Wself-assign-overloaded" 147 # elif defined(__clang__) 148 # if (__clang_major__ >= 7) 149 # pragma GCC diagnostic ignored "-Wself-assign-overloaded" 157 py::class_<Vector2>(
m,
"Vector2")
158 .def(py::init<float, float>())
166 .def(py::self / py::self)
167 .def(py::self += py::self)
168 .def(py::self -= py::self)
169 .def(py::self *=
float())
170 .def(py::self /=
float())
171 .def(py::self *= py::self)
172 .def(py::self /= py::self)
173 .def(
float() + py::self)
174 .def(
float() - py::self)
175 .def(
float() * py::self)
176 .def(
float() / py::self)
180 .def(py::self == py::self)
181 .def(py::self != py::self)
185 .def(
"__abs__", [](
const Vector2 &
v) {
return abs(v); });
187 m.attr(
"Vector") = m.attr(
"Vector2");
191 py::class_<C1>(
m,
"C1").def(py::init<>()).def(py::self + py::self);
193 py::class_<C2>(
m,
"C2")
195 .def(py::self + py::self)
196 .def(
"__add__", [](
const C2 &c2,
const C1 &c1) {
return c2 + c1; })
197 .def(
"__radd__", [](
const C2 &c2,
const C1 &c1) {
return c1 + c2; });
204 py::class_<NestABase>(
m,
"NestABase")
208 struct NestA : NestABase {
215 py::class_<NestA>(
m,
"NestA")
217 .def(py::self +=
int())
220 [](NestA &
a) -> NestABase & {
return (NestABase &)
a; },
221 py::return_value_policy::reference_internal);
222 m.def(
"get_NestA", [](
const NestA &a) {
return a.value; });
232 py::class_<NestB>(
m,
"NestB")
234 .def(py::self -=
int())
236 m.def(
"get_NestB", [](
const NestB &
b) {
return b.value; });
246 py::class_<NestC>(
m,
"NestC")
248 .def(py::self *=
int())
250 m.def(
"get_NestC", [](
const NestC &
c) {
return c.value; });
256 bool operator==(
const Comparable &rhs)
const {
return value == rhs.value; }
259 struct Hashable : Comparable {
260 explicit Hashable(
int value) : Comparable{value} {};
261 size_t hash()
const {
return static_cast<size_t>(
value); }
264 struct Hashable2 : Hashable {
265 using Hashable::Hashable;
268 py::class_<Comparable>(
m,
"Comparable").def(py::init<int>()).def(py::self == py::self);
270 py::class_<Hashable>(
m,
"Hashable")
271 .def(py::init<int>())
272 .def(py::self == py::self)
276 py::class_<Hashable2>(
m,
"Hashable2")
278 .def(py::init<int>())
279 .def(py::self == py::self);
282 py::class_<HashMe>(
m,
"HashMe").def(py::self == py::self);
284 m.def(
"get_unhashable_HashMe_set", []() {
return std::unordered_set<HashMe>{{
"one"}}; });
286 #if !defined(_MSC_VER) && !defined(__INTEL_COMPILER) 287 # pragma GCC diagnostic pop
bool operator!=(const Vector2 &v) const
Vector2 & operator/=(const Vector2 &v)
Vector2 operator+(float value) const
Vector2 & operator*=(const Vector2 &v)
Vector2 operator-(const Vector2 &v) const
std::size_t operator()(const HashMe &selector) const
friend Vector2 operator-(float f, const Vector2 &v)
void print_destroyed(T *inst, Values &&...values)
void print_copy_assigned(T *inst, Values &&...values)
void print_copy_created(T *inst, Values &&...values)
Vector2(float x, float y)
Vector2 operator/(const Vector2 &v) const
Vector2 & operator+=(const Vector2 &v)
Vector2 operator-(float value) const
Vector2 operator+(const Vector2 &v) const
Vector2 operator/(float value) const
std::string toString() const
Vector2 operator*(float value) const
void print_move_assigned(T *inst, Values &&...values)
Vector2 & operator-=(const Vector2 &v)
Vector2(Vector2 &&v) noexcept
Vector2 & operator=(const Vector2 &v)
Vector2 & operator=(Vector2 &&v) noexcept
Array< int, Dynamic, 1 > v
TEST_SUBMODULE(operators, m)
Vector2 & operator/=(float v)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
std::string abs(const Vector2 &)
friend Vector2 operator/(float f, const Vector2 &v)
friend Vector2 operator+(float f, const Vector2 &v)
friend Vector2 operator*(float f, const Vector2 &v)
Vector2 operator*(const Vector2 &v) const
size_t operator()(const Vector2 &)
void print_created(T *inst, Values &&...values)
Vector2 & operator*=(float v)
Vector2(const Vector2 &v)
bool operator==(const Vector2 &v) const
void print_move_created(T *inst, Values &&...values)
Vector2 operator-() const