test_methods_and_attributes.cpp
Go to the documentation of this file.
1 /*
2  tests/test_methods_and_attributes.cpp -- constructors, deconstructors, attribute access,
3  __str__, argument and return value conventions
4 
5  Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
6 
7  All rights reserved. Use of this source code is governed by a
8  BSD-style license that can be found in the LICENSE file.
9 */
10 
11 #include "constructor_stats.h"
12 #include "pybind11_tests.h"
13 
14 #if !defined(PYBIND11_OVERLOAD_CAST)
15 template <typename... Args>
16 using overload_cast_ = pybind11::detail::overload_cast_impl<Args...>;
17 #endif
18 
19 class ExampleMandA {
20 public:
22  explicit ExampleMandA(int value) : value(value) { print_created(this, value); }
24  explicit ExampleMandA(std::string &&) {}
25  ExampleMandA(ExampleMandA &&e) noexcept : value(e.value) { print_move_created(this); }
27 
28  std::string toString() const { return "ExampleMandA[value=" + std::to_string(value) + "]"; }
29 
30  void operator=(const ExampleMandA &e) {
31  print_copy_assigned(this);
32  value = e.value;
33  }
34  void operator=(ExampleMandA &&e) noexcept {
35  print_move_assigned(this);
36  value = e.value;
37  }
38 
39  // NOLINTNEXTLINE(performance-unnecessary-value-param)
40  void add1(ExampleMandA other) { value += other.value; } // passing by value
41  void add2(ExampleMandA &other) { value += other.value; } // passing by reference
42  void add3(const ExampleMandA &other) { value += other.value; } // passing by const reference
43  void add4(ExampleMandA *other) { value += other->value; } // passing by pointer
44  void add5(const ExampleMandA *other) { value += other->value; } // passing by const pointer
45 
46  void add6(int other) { value += other; } // passing by value
47  void add7(int &other) { value += other; } // passing by reference
48  void add8(const int &other) { value += other; } // passing by const reference
49  // NOLINTNEXTLINE(readability-non-const-parameter) Deliberately non-const for testing
50  void add9(int *other) { value += *other; } // passing by pointer
51  void add10(const int *other) { value += *other; } // passing by const pointer
52 
53  void consume_str(std::string &&) {}
54 
55  ExampleMandA self1() { return *this; } // return by value
56  ExampleMandA &self2() { return *this; } // return by reference
57  const ExampleMandA &self3() const { return *this; } // return by const reference
58  ExampleMandA *self4() { return this; } // return by pointer
59  const ExampleMandA *self5() const { return this; } // return by const pointer
60 
61  int internal1() const { return value; } // return by value
62  int &internal2() { return value; } // return by reference
63  const int &internal3() const { return value; } // return by const reference
64  int *internal4() { return &value; } // return by pointer
65  const int *internal5() { return &value; } // return by const pointer
66 
67  py::str overloaded() { return "()"; }
68  py::str overloaded(int) { return "(int)"; }
69  py::str overloaded(int, float) { return "(int, float)"; }
70  py::str overloaded(float, int) { return "(float, int)"; }
71  py::str overloaded(int, int) { return "(int, int)"; }
72  py::str overloaded(float, float) { return "(float, float)"; }
73  py::str overloaded(int) const { return "(int) const"; }
74  py::str overloaded(int, float) const { return "(int, float) const"; }
75  py::str overloaded(float, int) const { return "(float, int) const"; }
76  py::str overloaded(int, int) const { return "(int, int) const"; }
77  py::str overloaded(float, float) const { return "(float, float) const"; }
78 
79  static py::str overloaded(float) { return "static float"; }
80 
81  int value = 0;
82 };
83 
85  int value = 1;
86  static int static_value;
87 
88  int get() const { return value; }
89  void set(int v) { value = v; }
90 
91  static int static_get() { return static_value; }
92  static void static_set(int v) { static_value = v; }
93 };
95 
97  int value = 99;
98  static int static_value;
99 };
101 
102 struct TestPropRVP {
103  UserType v1{1};
104  UserType v2{1};
105  static UserType sv1;
106  static UserType sv2;
107 
108  const UserType &get1() const { return v1; }
109  const UserType &get2() const { return v2; }
110  UserType get_rvalue() const { return v2; }
111  void set1(int v) { v1.set(v); }
112  void set2(int v) { v2.set(v); }
113 };
114 UserType TestPropRVP::sv1(1);
115 UserType TestPropRVP::sv2(1);
116 
117 // Test None-allowed py::arg argument policy
118 class NoneTester {
119 public:
120  int answer = 42;
121 };
122 int none1(const NoneTester &obj) { return obj.answer; }
123 int none2(NoneTester *obj) { return obj ? obj->answer : -1; }
124 int none3(std::shared_ptr<NoneTester> &obj) { return obj ? obj->answer : -1; }
125 int none4(std::shared_ptr<NoneTester> *obj) { return obj && *obj ? (*obj)->answer : -1; }
126 int none5(const std::shared_ptr<NoneTester> &obj) { return obj ? obj->answer : -1; }
127 
128 // Issue #2778: implicit casting from None to object (not pointer)
130 public:
131  int answer = -1;
132  NoneCastTester() = default;
133  explicit NoneCastTester(int v) : answer(v) {}
134 };
135 
136 struct StrIssue {
137  int val = -1;
138 
139  StrIssue() = default;
140  explicit StrIssue(int i) : val{i} {}
141 };
142 
143 // Issues #854, #910: incompatible function args when member function/pointer is in unregistered
144 // base class
146 public:
147  void do_nothing() const {}
148  void increase_value() {
149  rw_value++;
150  ro_value += 0.25;
151  }
152  void set_int(int v) { rw_value = v; }
153  int get_int() const { return rw_value; }
154  double get_double() const { return ro_value; }
155  int rw_value = 42;
156  double ro_value = 1.25;
157 };
159 public:
160  using UnregisteredBase::UnregisteredBase;
161  double sum() const { return rw_value + ro_value; }
162 };
163 
164 // Test explicit lvalue ref-qualification
165 struct RefQualified {
166  int value = 0;
167 
168  void refQualified(int other) & { value += other; }
169  int constRefQualified(int other) const & { return value + other; }
170 };
171 
172 // Test rvalue ref param
174  std::size_t func1(std::string &&s) { return s.size(); }
175  std::size_t func2(std::string &&s) const { return s.size(); }
176  std::size_t func3(std::string &&s) & { return s.size(); }
177  std::size_t func4(std::string &&s) const & { return s.size(); }
178 };
179 
180 namespace pybind11_tests {
181 namespace exercise_is_setter {
182 
183 struct FieldBase {
184  int int_value() const { return int_value_; }
185 
188  return *this;
189  }
190 
191 private:
192  int int_value_ = -99;
193 };
194 
195 struct Field : FieldBase {};
196 
198  py::module sm = m.def_submodule("exercise_is_setter");
199  // NOTE: FieldBase is not wrapped, therefore ...
200  py::class_<Field>(sm, "Field")
201  .def(py::init<>())
202  .def_property(
203  "int_value",
205  &Field::SetIntValue // ... the `FieldBase &` return value here cannot be converted.
206  );
207 }
208 
209 } // namespace exercise_is_setter
210 } // namespace pybind11_tests
211 
212 TEST_SUBMODULE(methods_and_attributes, m) {
213  // test_methods_and_attributes
214  py::class_<ExampleMandA> emna(m, "ExampleMandA");
215  emna.def(py::init<>())
216  .def(py::init<int>())
217  .def(py::init<std::string &&>())
218  .def(py::init<const ExampleMandA &>())
219  .def("add1", &ExampleMandA::add1)
220  .def("add2", &ExampleMandA::add2)
221  .def("add3", &ExampleMandA::add3)
222  .def("add4", &ExampleMandA::add4)
223  .def("add5", &ExampleMandA::add5)
224  .def("add6", &ExampleMandA::add6)
225  .def("add7", &ExampleMandA::add7)
226  .def("add8", &ExampleMandA::add8)
227  .def("add9", &ExampleMandA::add9)
228  .def("add10", &ExampleMandA::add10)
229  .def("consume_str", &ExampleMandA::consume_str)
230  .def("self1", &ExampleMandA::self1)
231  .def("self2", &ExampleMandA::self2)
232  .def("self3", &ExampleMandA::self3)
233  .def("self4", &ExampleMandA::self4)
234  .def("self5", &ExampleMandA::self5)
235  .def("internal1", &ExampleMandA::internal1)
236  .def("internal2", &ExampleMandA::internal2)
237  .def("internal3", &ExampleMandA::internal3)
238  .def("internal4", &ExampleMandA::internal4)
239  .def("internal5", &ExampleMandA::internal5)
240 #if defined(PYBIND11_OVERLOAD_CAST)
241  .def("overloaded", py::overload_cast<>(&ExampleMandA::overloaded))
242  .def("overloaded", py::overload_cast<int>(&ExampleMandA::overloaded))
243  .def("overloaded", py::overload_cast<int, float>(&ExampleMandA::overloaded))
244  .def("overloaded", py::overload_cast<float, int>(&ExampleMandA::overloaded))
245  .def("overloaded", py::overload_cast<int, int>(&ExampleMandA::overloaded))
246  .def("overloaded", py::overload_cast<float, float>(&ExampleMandA::overloaded))
247  .def("overloaded_float", py::overload_cast<float, float>(&ExampleMandA::overloaded))
248  .def("overloaded_const", py::overload_cast<int>(&ExampleMandA::overloaded, py::const_))
249  .def("overloaded_const",
250  py::overload_cast<int, float>(&ExampleMandA::overloaded, py::const_))
251  .def("overloaded_const",
252  py::overload_cast<float, int>(&ExampleMandA::overloaded, py::const_))
253  .def("overloaded_const",
254  py::overload_cast<int, int>(&ExampleMandA::overloaded, py::const_))
255  .def("overloaded_const",
256  py::overload_cast<float, float>(&ExampleMandA::overloaded, py::const_))
257 #else
258  // Use both the traditional static_cast method and the C++11 compatible overload_cast_
259  .def("overloaded", overload_cast_<>()(&ExampleMandA::overloaded))
260  .def("overloaded", overload_cast_<int>()(&ExampleMandA::overloaded))
262  .def("overloaded", static_cast<py::str (ExampleMandA::*)(float, int)>(&ExampleMandA::overloaded))
263  .def("overloaded", static_cast<py::str (ExampleMandA::*)(int, int)>(&ExampleMandA::overloaded))
264  .def("overloaded", static_cast<py::str (ExampleMandA::*)(float, float)>(&ExampleMandA::overloaded))
265  .def("overloaded_float", overload_cast_<float, float>()(&ExampleMandA::overloaded))
266  .def("overloaded_const", overload_cast_<int >()(&ExampleMandA::overloaded, py::const_))
267  .def("overloaded_const", overload_cast_<int, float>()(&ExampleMandA::overloaded, py::const_))
268  .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(float, int) const>(&ExampleMandA::overloaded))
269  .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(int, int) const>(&ExampleMandA::overloaded))
270  .def("overloaded_const", static_cast<py::str (ExampleMandA::*)(float, float) const>(&ExampleMandA::overloaded))
271 #endif
272  // test_no_mixed_overloads
273  // Raise error if trying to mix static/non-static overloads on the same name:
274  .def_static("add_mixed_overloads1",
275  []() {
276  auto emna = py::reinterpret_borrow<py::class_<ExampleMandA>>(
277  py::module_::import("pybind11_tests.methods_and_attributes")
278  .attr("ExampleMandA"));
279  emna.def("overload_mixed1",
280  static_cast<py::str (ExampleMandA::*)(int, int)>(
282  .def_static(
283  "overload_mixed1",
284  static_cast<py::str (*)(float)>(&ExampleMandA::overloaded));
285  })
286  .def_static("add_mixed_overloads2",
287  []() {
288  auto emna = py::reinterpret_borrow<py::class_<ExampleMandA>>(
289  py::module_::import("pybind11_tests.methods_and_attributes")
290  .attr("ExampleMandA"));
291  emna.def_static("overload_mixed2",
292  static_cast<py::str (*)(float)>(&ExampleMandA::overloaded))
293  .def("overload_mixed2",
294  static_cast<py::str (ExampleMandA::*)(int, int)>(
296  })
297  .def("__str__", &ExampleMandA::toString)
298  .def_readwrite("value", &ExampleMandA::value);
299 
300  // test_copy_method
301  // Issue #443: can't call copied methods in Python 3
302  emna.attr("add2b") = emna.attr("add2");
303 
304  // test_properties, test_static_properties, test_static_cls
305  py::class_<TestProperties>(m, "TestProperties")
306  .def(py::init<>())
307  .def_readonly("def_readonly", &TestProperties::value)
308  .def_readwrite("def_readwrite", &TestProperties::value)
309  .def_property("def_writeonly", nullptr, [](TestProperties &s, int v) { s.value = v; })
310  .def_property("def_property_writeonly", nullptr, &TestProperties::set)
311  .def_property_readonly("def_property_readonly", &TestProperties::get)
312  .def_property("def_property", &TestProperties::get, &TestProperties::set)
313  .def_property("def_property_impossible", nullptr, nullptr)
314  .def_readonly_static("def_readonly_static", &TestProperties::static_value)
315  .def_readwrite_static("def_readwrite_static", &TestProperties::static_value)
316  .def_property_static("def_writeonly_static",
317  nullptr,
318  [](const py::object &, int v) { TestProperties::static_value = v; })
319  .def_property_readonly_static(
320  "def_property_readonly_static",
321  [](const py::object &) { return TestProperties::static_get(); })
322  .def_property_static(
323  "def_property_writeonly_static",
324  nullptr,
325  [](const py::object &, int v) { return TestProperties::static_set(v); })
326  .def_property_static(
327  "def_property_static",
328  [](const py::object &) { return TestProperties::static_get(); },
329  [](const py::object &, int v) { TestProperties::static_set(v); })
330  .def_property_static(
331  "static_cls",
332  [](py::object cls) { return cls; },
333  [](const py::object &cls, const py::function &f) { f(cls); });
334 
335  py::class_<TestPropertiesOverride, TestProperties>(m, "TestPropertiesOverride")
336  .def(py::init<>())
337  .def_readonly("def_readonly", &TestPropertiesOverride::value)
338  .def_readonly_static("def_readonly_static", &TestPropertiesOverride::static_value);
339 
340  auto static_get1 = [](const py::object &) -> const UserType & { return TestPropRVP::sv1; };
341  auto static_get2 = [](const py::object &) -> const UserType & { return TestPropRVP::sv2; };
342  auto static_set1 = [](const py::object &, int v) { TestPropRVP::sv1.set(v); };
343  auto static_set2 = [](const py::object &, int v) { TestPropRVP::sv2.set(v); };
344  auto rvp_copy = py::return_value_policy::copy;
345 
346  // test_property_return_value_policies
347  py::class_<TestPropRVP>(m, "TestPropRVP")
348  .def(py::init<>())
349  .def_property_readonly("ro_ref", &TestPropRVP::get1)
350  .def_property_readonly("ro_copy", &TestPropRVP::get2, rvp_copy)
351  .def_property_readonly("ro_func", py::cpp_function(&TestPropRVP::get2, rvp_copy))
352  .def_property("rw_ref", &TestPropRVP::get1, &TestPropRVP::set1)
353  .def_property("rw_copy", &TestPropRVP::get2, &TestPropRVP::set2, rvp_copy)
354  .def_property(
355  "rw_func", py::cpp_function(&TestPropRVP::get2, rvp_copy), &TestPropRVP::set2)
356  .def_property_readonly_static("static_ro_ref", static_get1)
357  .def_property_readonly_static("static_ro_copy", static_get2, rvp_copy)
358  .def_property_readonly_static("static_ro_func", py::cpp_function(static_get2, rvp_copy))
359  .def_property_static("static_rw_ref", static_get1, static_set1)
360  .def_property_static("static_rw_copy", static_get2, static_set2, rvp_copy)
361  .def_property_static(
362  "static_rw_func", py::cpp_function(static_get2, rvp_copy), static_set2)
363  // test_property_rvalue_policy
364  .def_property_readonly("rvalue", &TestPropRVP::get_rvalue)
365  .def_property_readonly_static("static_rvalue",
366  [](const py::object &) { return UserType(1); });
367 
368  // test_metaclass_override
369  struct MetaclassOverride {};
370  py::class_<MetaclassOverride>(m, "MetaclassOverride", py::metaclass((PyObject *) &PyType_Type))
371  .def_property_readonly_static("readonly", [](const py::object &) { return 1; });
372 
373  // test_overload_ordering
374  m.def("overload_order", [](const std::string &) { return 1; });
375  m.def("overload_order", [](const std::string &) { return 2; });
376  m.def("overload_order", [](int) { return 3; });
377  m.def("overload_order", [](int) { return 4; }, py::prepend{});
378 
379 #if !defined(PYPY_VERSION)
380  // test_dynamic_attributes
381  class DynamicClass {
382  public:
383  DynamicClass() { print_default_created(this); }
384  DynamicClass(const DynamicClass &) = delete;
385  ~DynamicClass() { print_destroyed(this); }
386  };
387  py::class_<DynamicClass>(m, "DynamicClass", py::dynamic_attr()).def(py::init());
388 
389  class CppDerivedDynamicClass : public DynamicClass {};
390  py::class_<CppDerivedDynamicClass, DynamicClass>(m, "CppDerivedDynamicClass").def(py::init());
391 #endif
392 
393  // test_bad_arg_default
394  // Issue/PR #648: bad arg default debugging output
395 #if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
396  m.attr("detailed_error_messages_enabled") = true;
397 #else
398  m.attr("detailed_error_messages_enabled") = false;
399 #endif
400  m.def("bad_arg_def_named", [] {
401  auto m = py::module_::import("pybind11_tests");
402  m.def(
403  "should_fail",
404  [](int, UnregisteredType) {},
405  py::arg(),
406  py::arg("a") = UnregisteredType());
407  });
408  m.def("bad_arg_def_unnamed", [] {
409  auto m = py::module_::import("pybind11_tests");
410  m.def(
411  "should_fail",
412  [](int, UnregisteredType) {},
413  py::arg(),
414  py::arg() = UnregisteredType());
415  });
416 
417  // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
418 
419  // test_accepts_none
420  py::class_<NoneTester, std::shared_ptr<NoneTester>>(m, "NoneTester").def(py::init<>());
421  m.def("no_none1", &none1, py::arg{}.none(false));
422  m.def("no_none2", &none2, py::arg{}.none(false));
423  m.def("no_none3", &none3, py::arg{}.none(false));
424  m.def("no_none4", &none4, py::arg{}.none(false));
425  m.def("no_none5", &none5, py::arg{}.none(false));
426  m.def("ok_none1", &none1);
427  m.def("ok_none2", &none2, py::arg{}.none(true));
428  m.def("ok_none3", &none3);
429  m.def("ok_none4", &none4, py::arg{}.none(true));
430  m.def("ok_none5", &none5);
431 
432  m.def("no_none_kwarg", &none2, "a"_a.none(false));
433  m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), "a"_a.none(false));
434 
435  // test_casts_none
436  // Issue #2778: implicit casting from None to object (not pointer)
437  py::class_<NoneCastTester>(m, "NoneCastTester")
438  .def(py::init<>())
439  .def(py::init<int>())
440  .def(py::init([](py::none const &) { return NoneCastTester{}; }));
441  py::implicitly_convertible<py::none, NoneCastTester>();
442  m.def("ok_obj_or_none", [](NoneCastTester const &foo) { return foo.answer; });
443 
444  // test_str_issue
445  // Issue #283: __str__ called on uninitialized instance when constructor arguments invalid
446  py::class_<StrIssue>(m, "StrIssue")
447  .def(py::init<int>())
448  .def(py::init<>())
449  .def("__str__",
450  [](const StrIssue &si) { return "StrIssue[" + std::to_string(si.val) + "]"; });
451 
452  // test_unregistered_base_implementations
453  //
454  // Issues #854/910: incompatible function args when member function/pointer is in unregistered
455  // base class The methods and member pointers below actually resolve to members/pointers in
456  // UnregisteredBase; before this test/fix they would be registered via lambda with a first
457  // argument of an unregistered type, and thus uncallable.
458  py::class_<RegisteredDerived>(m, "RegisteredDerived")
459  .def(py::init<>())
460  .def("do_nothing", &RegisteredDerived::do_nothing)
461  .def("increase_value", &RegisteredDerived::increase_value)
462  .def_readwrite("rw_value", &RegisteredDerived::rw_value)
463  .def_readonly("ro_value", &RegisteredDerived::ro_value)
464  // Uncommenting the next line should trigger a static_assert:
465  // .def_readwrite("fails", &UserType::value)
466  // Uncommenting the next line should trigger a static_assert:
467  // .def_readonly("fails", &UserType::value)
468  .def_property("rw_value_prop", &RegisteredDerived::get_int, &RegisteredDerived::set_int)
469  .def_property_readonly("ro_value_prop", &RegisteredDerived::get_double)
470  // This one is in the registered class:
471  .def("sum", &RegisteredDerived::sum);
472 
473  using Adapted
474  = decltype(py::method_adaptor<RegisteredDerived>(&RegisteredDerived::do_nothing));
475  static_assert(std::is_same<Adapted, void (RegisteredDerived::*)() const>::value, "");
476 
477  // test_methods_and_attributes
478  py::class_<RefQualified>(m, "RefQualified")
479  .def(py::init<>())
480  .def_readonly("value", &RefQualified::value)
481  .def("refQualified", &RefQualified::refQualified)
482  .def("constRefQualified", &RefQualified::constRefQualified);
483 
484  py::class_<RValueRefParam>(m, "RValueRefParam")
485  .def(py::init<>())
486  .def("func1", &RValueRefParam::func1)
487  .def("func2", &RValueRefParam::func2)
488  .def("func3", &RValueRefParam::func3)
489  .def("func4", &RValueRefParam::func4);
490 
492 }
UnregisteredBase::set_int
void set_int(int v)
Definition: test_methods_and_attributes.cpp:152
TestPropRVP::get_rvalue
UserType get_rvalue() const
Definition: test_methods_and_attributes.cpp:110
ExampleMandA::add1
void add1(ExampleMandA other)
Definition: test_methods_and_attributes.cpp:40
ExampleMandA::overloaded
py::str overloaded(float, float)
Definition: test_methods_and_attributes.cpp:72
ExampleMandA::overloaded
py::str overloaded(int)
Definition: test_methods_and_attributes.cpp:68
RefQualified::value
int value
Definition: test_methods_and_attributes.cpp:166
pybind11_tests::exercise_is_setter::FieldBase::int_value_
int int_value_
Definition: test_methods_and_attributes.cpp:192
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
UnregisteredBase::get_int
int get_int() const
Definition: test_methods_and_attributes.cpp:153
ExampleMandA::add7
void add7(int &other)
Definition: test_methods_and_attributes.cpp:47
ExampleMandA::consume_str
void consume_str(std::string &&)
Definition: test_methods_and_attributes.cpp:53
TestPropRVP::sv1
static UserType sv1
Definition: test_methods_and_attributes.cpp:105
ExampleMandA::self5
const ExampleMandA * self5() const
Definition: test_methods_and_attributes.cpp:59
ExampleMandA::operator=
void operator=(ExampleMandA &&e) noexcept
Definition: test_methods_and_attributes.cpp:34
ExampleMandA::internal1
int internal1() const
Definition: test_methods_and_attributes.cpp:61
RValueRefParam::func2
std::size_t func2(std::string &&s) const
Definition: test_methods_and_attributes.cpp:175
StrIssue
Definition: test_methods_and_attributes.cpp:136
const_
static constexpr auto const_
Definition: wrap/pybind11/include/pybind11/detail/common.h:1138
UnregisteredBase::get_double
double get_double() const
Definition: test_methods_and_attributes.cpp:154
RefQualified::constRefQualified
int constRefQualified(int other) const &
Definition: test_methods_and_attributes.cpp:169
UnregisteredBase::do_nothing
void do_nothing() const
Definition: test_methods_and_attributes.cpp:147
TestPropRVP::set2
void set2(int v)
Definition: test_methods_and_attributes.cpp:112
ExampleMandA::toString
std::string toString() const
Definition: test_methods_and_attributes.cpp:28
copy
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:29
UnregisteredType
Dummy type which is not exported anywhere – something to trigger a conversion error.
Definition: pybind11_tests.h:25
ExampleMandA::ExampleMandA
ExampleMandA(std::string &&)
Definition: test_methods_and_attributes.cpp:24
pybind11_tests::exercise_is_setter::FieldBase::int_value
int int_value() const
Definition: test_methods_and_attributes.cpp:184
RefQualified
Definition: test_methods_and_attributes.cpp:165
NoneTester::answer
int answer
Definition: test_methods_and_attributes.cpp:120
ExampleMandA::add10
void add10(const int *other)
Definition: test_methods_and_attributes.cpp:51
ExampleMandA
Definition: test_methods_and_attributes.cpp:19
TestProperties::get
int get() const
Definition: test_methods_and_attributes.cpp:88
none3
int none3(std::shared_ptr< NoneTester > &obj)
Definition: test_methods_and_attributes.cpp:124
NoneCastTester
Definition: test_methods_and_attributes.cpp:129
TestPropRVP::sv2
static UserType sv2
Definition: test_methods_and_attributes.cpp:106
ExampleMandA::overloaded
py::str overloaded(float, int) const
Definition: test_methods_and_attributes.cpp:75
NoneCastTester::answer
int answer
Definition: test_methods_and_attributes.cpp:131
constructor_stats.h
TestProperties::value
int value
Definition: test_methods_and_attributes.cpp:85
print_copy_created
void print_copy_created(T *inst, Values &&...values)
Definition: constructor_stats.h:282
RegisteredDerived::sum
double sum() const
Definition: test_methods_and_attributes.cpp:161
print_default_created
void print_default_created(T *inst, Values &&...values)
Definition: constructor_stats.h:304
NoneCastTester::NoneCastTester
NoneCastTester(int v)
Definition: test_methods_and_attributes.cpp:133
StrIssue::val
int val
Definition: test_methods_and_attributes.cpp:137
TestPropertiesOverride::value
int value
Definition: test_methods_and_attributes.cpp:97
UnregisteredBase::rw_value
int rw_value
Definition: test_methods_and_attributes.cpp:155
pybind11_tests::exercise_is_setter::Field
Definition: test_methods_and_attributes.cpp:195
TestPropertiesOverride::static_value
static int static_value
Definition: test_methods_and_attributes.cpp:98
ExampleMandA::overloaded
py::str overloaded(int, float) const
Definition: test_methods_and_attributes.cpp:74
TestPropRVP::v1
UserType v1
Definition: test_methods_and_attributes.cpp:103
module
module_ module
Definition: pybind11.h:1367
ExampleMandA::add6
void add6(int other)
Definition: test_methods_and_attributes.cpp:46
ExampleMandA::self2
ExampleMandA & self2()
Definition: test_methods_and_attributes.cpp:56
TestProperties::static_value
static int static_value
Definition: test_methods_and_attributes.cpp:86
ExampleMandA::add8
void add8(const int &other)
Definition: test_methods_and_attributes.cpp:48
print_copy_assigned
void print_copy_assigned(T *inst, Values &&...values)
Definition: constructor_stats.h:294
ExampleMandA::add4
void add4(ExampleMandA *other)
Definition: test_methods_and_attributes.cpp:43
ExampleMandA::self4
ExampleMandA * self4()
Definition: test_methods_and_attributes.cpp:58
ExampleMandA::operator=
void operator=(const ExampleMandA &e)
Definition: test_methods_and_attributes.cpp:30
ExampleMandA::overloaded
py::str overloaded()
Definition: test_methods_and_attributes.cpp:67
ExampleMandA::internal2
int & internal2()
Definition: test_methods_and_attributes.cpp:62
TestPropertiesOverride
Definition: test_methods_and_attributes.cpp:96
StrIssue::StrIssue
StrIssue(int i)
Definition: test_methods_and_attributes.cpp:140
TestPropRVP::get1
const UserType & get1() const
Definition: test_methods_and_attributes.cpp:108
foo
void foo(CV_QUALIFIER Matrix3d &m)
Definition: block_nonconst_ctor_on_const_xpr_0.cpp:11
NoneTester
Definition: test_methods_and_attributes.cpp:118
TestPropRVP::v2
UserType v2
Definition: test_methods_and_attributes.cpp:104
RValueRefParam
Definition: test_methods_and_attributes.cpp:173
ExampleMandA::self1
ExampleMandA self1()
Definition: test_methods_and_attributes.cpp:55
RValueRefParam::func1
std::size_t func1(std::string &&s)
Definition: test_methods_and_attributes.cpp:174
UnregisteredBase::ro_value
double ro_value
Definition: test_methods_and_attributes.cpp:156
none5
int none5(const std::shared_ptr< NoneTester > &obj)
Definition: test_methods_and_attributes.cpp:126
RegisteredDerived
Definition: test_methods_and_attributes.cpp:158
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
ExampleMandA::internal4
int * internal4()
Definition: test_methods_and_attributes.cpp:64
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
none2
int none2(NoneTester *obj)
Definition: test_methods_and_attributes.cpp:123
init
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:2006
size_t
std::size_t size_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:490
pybind11_tests
Definition: test_methods_and_attributes.cpp:180
ExampleMandA::internal5
const int * internal5()
Definition: test_methods_and_attributes.cpp:65
ExampleMandA::add2
void add2(ExampleMandA &other)
Definition: test_methods_and_attributes.cpp:41
ExampleMandA::ExampleMandA
ExampleMandA(int value)
Definition: test_methods_and_attributes.cpp:22
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
ExampleMandA::overloaded
py::str overloaded(int, int)
Definition: test_methods_and_attributes.cpp:71
ExampleMandA::add3
void add3(const ExampleMandA &other)
Definition: test_methods_and_attributes.cpp:42
UnregisteredBase::increase_value
void increase_value()
Definition: test_methods_and_attributes.cpp:148
RValueRefParam::func4
std::size_t func4(std::string &&s) const &
Definition: test_methods_and_attributes.cpp:177
ExampleMandA::overloaded
py::str overloaded(int, float)
Definition: test_methods_and_attributes.cpp:69
ExampleMandA::overloaded
py::str overloaded(float, float) const
Definition: test_methods_and_attributes.cpp:77
pybind11_tests::exercise_is_setter::add_bindings
void add_bindings(py::module &m)
Definition: test_methods_and_attributes.cpp:197
ExampleMandA::overloaded
py::str overloaded(int, int) const
Definition: test_methods_and_attributes.cpp:76
print_move_created
void print_move_created(T *inst, Values &&...values)
Definition: constructor_stats.h:288
pybind11_tests::exercise_is_setter::FieldBase
Definition: test_methods_and_attributes.cpp:183
TEST_SUBMODULE
TEST_SUBMODULE(methods_and_attributes, m)
Definition: test_methods_and_attributes.cpp:212
ExampleMandA::ExampleMandA
ExampleMandA(ExampleMandA &&e) noexcept
Definition: test_methods_and_attributes.cpp:25
StrIssue::StrIssue
StrIssue()=default
pybind11_tests.h
TestProperties::set
void set(int v)
Definition: test_methods_and_attributes.cpp:89
ExampleMandA::ExampleMandA
ExampleMandA()
Definition: test_methods_and_attributes.cpp:21
none1
int none1(const NoneTester &obj)
Definition: test_methods_and_attributes.cpp:122
print_destroyed
void print_destroyed(T *inst, Values &&...values)
Definition: constructor_stats.h:314
ExampleMandA::~ExampleMandA
~ExampleMandA()
Definition: test_methods_and_attributes.cpp:26
TestProperties
Definition: test_methods_and_attributes.cpp:84
ExampleMandA::internal3
const int & internal3() const
Definition: test_methods_and_attributes.cpp:63
TestPropRVP::get2
const UserType & get2() const
Definition: test_methods_and_attributes.cpp:109
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
RefQualified::refQualified
void refQualified(int other) &
Definition: test_methods_and_attributes.cpp:168
ExampleMandA::add5
void add5(const ExampleMandA *other)
Definition: test_methods_and_attributes.cpp:44
ExampleMandA::overloaded
static py::str overloaded(float)
Definition: test_methods_and_attributes.cpp:79
none4
int none4(std::shared_ptr< NoneTester > *obj)
Definition: test_methods_and_attributes.cpp:125
print_move_assigned
void print_move_assigned(T *inst, Values &&...values)
Definition: constructor_stats.h:299
TestProperties::static_set
static void static_set(int v)
Definition: test_methods_and_attributes.cpp:92
TestProperties::static_get
static int static_get()
Definition: test_methods_and_attributes.cpp:91
ExampleMandA::overloaded
py::str overloaded(float, int)
Definition: test_methods_and_attributes.cpp:70
NoneCastTester::NoneCastTester
NoneCastTester()=default
TestPropRVP
Definition: test_methods_and_attributes.cpp:102
ExampleMandA::add9
void add9(int *other)
Definition: test_methods_and_attributes.cpp:50
TestPropRVP::set1
void set1(int v)
Definition: test_methods_and_attributes.cpp:111
ExampleMandA::ExampleMandA
ExampleMandA(const ExampleMandA &e)
Definition: test_methods_and_attributes.cpp:23
pybind11_tests::exercise_is_setter::FieldBase::SetIntValue
FieldBase & SetIntValue(int int_value)
Definition: test_methods_and_attributes.cpp:186
RValueRefParam::func3
std::size_t func3(std::string &&s) &
Definition: test_methods_and_attributes.cpp:176
ExampleMandA::overloaded
py::str overloaded(int) const
Definition: test_methods_and_attributes.cpp:73
ExampleMandA::self3
const ExampleMandA & self3() const
Definition: test_methods_and_attributes.cpp:57
gtsam.examples.ShonanAveragingCLI.str
str
Definition: ShonanAveragingCLI.py:115
test_callbacks.value
value
Definition: test_callbacks.py:160
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
UnregisteredBase
Definition: test_methods_and_attributes.cpp:145
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
ExampleMandA::value
int value
Definition: test_methods_and_attributes.cpp:81
print_created
void print_created(T *inst, Values &&...values)
Definition: constructor_stats.h:309
overload_cast_
pybind11::detail::overload_cast_impl< Args... > overload_cast_
Definition: test_methods_and_attributes.cpp:16


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:15:58