test_virtual_functions.cpp
Go to the documentation of this file.
1 /*
2  tests/test_virtual_functions.cpp -- overriding virtual functions from Python
3 
4  Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 #include <pybind11/functional.h>
11 
12 #include "constructor_stats.h"
13 #include "pybind11_tests.h"
14 
15 #include <thread>
16 
17 /* This is an example class that we'll want to be able to extend from Python */
18 class ExampleVirt {
19 public:
20  explicit ExampleVirt(int state) : state(state) { print_created(this, state); }
22  ExampleVirt(ExampleVirt &&e) noexcept : state(e.state) {
23  print_move_created(this);
24  e.state = 0;
25  }
26  virtual ~ExampleVirt() { print_destroyed(this); }
27 
28  virtual int run(int value) {
29  py::print("Original implementation of "
30  "ExampleVirt::run(state={}, value={}, str1={}, str2={})"_s.format(
31  state, value, get_string1(), *get_string2()));
32  return state + value;
33  }
34 
35  virtual bool run_bool() = 0;
36  virtual void pure_virtual() = 0;
37 
38  // Returning a reference/pointer to a type converted from python (numbers, strings, etc.) is a
39  // bit trickier, because the actual int& or std::string& or whatever only exists temporarily,
40  // so we have to handle it specially in the trampoline class (see below).
41  virtual const std::string &get_string1() { return str1; }
42  virtual const std::string *get_string2() { return &str2; }
43 
44 private:
45  int state;
46  const std::string str1{"default1"}, str2{"default2"};
47 };
48 
49 /* This is a wrapper class that must be generated */
50 class PyExampleVirt : public ExampleVirt {
51 public:
52  using ExampleVirt::ExampleVirt; /* Inherit constructors */
53 
54  int run(int value) override {
55  /* Generate wrapping code that enables native function overloading */
56  PYBIND11_OVERRIDE(int, /* Return type */
57  ExampleVirt, /* Parent class */
58  run, /* Name of function */
59  value /* Argument(s) */
60  );
61  }
62 
63  bool run_bool() override {
64  PYBIND11_OVERRIDE_PURE(bool, /* Return type */
65  ExampleVirt, /* Parent class */
66  run_bool, /* Name of function */
67  /* This function has no arguments. The trailing comma
68  in the previous line is needed for some compilers */
69  );
70  }
71 
72  void pure_virtual() override {
73  PYBIND11_OVERRIDE_PURE(void, /* Return type */
74  ExampleVirt, /* Parent class */
75  pure_virtual, /* Name of function */
76  /* This function has no arguments. The trailing comma
77  in the previous line is needed for some compilers */
78  );
79  }
80 
81  // We can return reference types for compatibility with C++ virtual interfaces that do so, but
82  // note they have some significant limitations (see the documentation).
83  const std::string &get_string1() override {
84  PYBIND11_OVERRIDE(const std::string &, /* Return type */
85  ExampleVirt, /* Parent class */
86  get_string1, /* Name of function */
87  /* (no arguments) */
88  );
89  }
90 
91  const std::string *get_string2() override {
92  PYBIND11_OVERRIDE(const std::string *, /* Return type */
93  ExampleVirt, /* Parent class */
94  get_string2, /* Name of function */
95  /* (no arguments) */
96  );
97  }
98 };
99 
100 class NonCopyable {
101 public:
102  NonCopyable(int a, int b) : value{new int(a * b)} { print_created(this, a, b); }
103  NonCopyable(NonCopyable &&o) noexcept : value{std::move(o.value)} { print_move_created(this); }
104  NonCopyable(const NonCopyable &) = delete;
105  NonCopyable() = delete;
106  void operator=(const NonCopyable &) = delete;
107  void operator=(NonCopyable &&) = delete;
108  std::string get_value() const {
109  if (value) {
110  return std::to_string(*value);
111  }
112  return "(null)";
113  }
115 
116 private:
117  std::unique_ptr<int> value;
118 };
119 
120 // This is like the above, but is both copy and movable. In effect this means it should get moved
121 // when it is not referenced elsewhere, but copied if it is still referenced.
122 class Movable {
123 public:
124  Movable(int a, int b) : value{a + b} { print_created(this, a, b); }
125  Movable(const Movable &m) : value{m.value} { print_copy_created(this); }
126  Movable(Movable &&m) noexcept : value{m.value} { print_move_created(this); }
127  std::string get_value() const { return std::to_string(value); }
129 
130 private:
131  int value;
132 };
133 
134 class NCVirt {
135 public:
136  virtual ~NCVirt() = default;
137  NCVirt() = default;
138  NCVirt(const NCVirt &) = delete;
139  virtual NonCopyable get_noncopyable(int a, int b) { return NonCopyable(a, b); }
140  virtual Movable get_movable(int a, int b) = 0;
141 
142  std::string print_nc(int a, int b) { return get_noncopyable(a, b).get_value(); }
143  std::string print_movable(int a, int b) { return get_movable(a, b).get_value(); }
144 };
145 class NCVirtTrampoline : public NCVirt {
146 #if !defined(__INTEL_COMPILER) && !defined(__CUDACC__) && !defined(__PGIC__)
147  NonCopyable get_noncopyable(int a, int b) override {
148  PYBIND11_OVERRIDE(NonCopyable, NCVirt, get_noncopyable, a, b);
149  }
150 #endif
151  Movable get_movable(int a, int b) override {
152  PYBIND11_OVERRIDE_PURE(Movable, NCVirt, get_movable, a, b);
153  }
154 };
155 
156 struct Base {
157  virtual std::string dispatch() const = 0;
158  virtual ~Base() = default;
159  Base() = default;
160  Base(const Base &) = delete;
161 };
162 
163 struct DispatchIssue : Base {
164  std::string dispatch() const override {
165  PYBIND11_OVERRIDE_PURE(std::string, Base, dispatch, /* no arguments */);
166  }
167 };
168 
169 // An abstract adder class that uses visitor pattern to add two data
170 // objects and send the result to the visitor functor
171 struct AdderBase {
172  struct Data {};
173  using DataVisitor = std::function<void(const Data &)>;
174 
175  virtual void
176  operator()(const Data &first, const Data &second, const DataVisitor &visitor) const = 0;
177  virtual ~AdderBase() = default;
178  AdderBase() = default;
179  AdderBase(const AdderBase &) = delete;
180 };
181 
182 struct Adder : AdderBase {
183  void
184  operator()(const Data &first, const Data &second, const DataVisitor &visitor) const override {
186  void, AdderBase, "__call__", operator(), first, second, visitor);
187  }
188 };
189 
190 static void test_gil() {
191  {
192  py::gil_scoped_acquire lock;
193  py::print("1st lock acquired");
194  }
195 
196  {
197  py::gil_scoped_acquire lock;
198  py::print("2nd lock acquired");
199  }
200 }
201 
202 static void test_gil_from_thread() {
203  py::gil_scoped_release release;
204 
205  std::thread t(test_gil);
206  t.join();
207 }
208 
210 
211 public:
212  virtual int func() { return 0; }
213 
214  test_override_cache_helper() = default;
215  virtual ~test_override_cache_helper() = default;
216  // Non-copyable
217  test_override_cache_helper &operator=(test_override_cache_helper const &Right) = delete;
219 };
220 
223 };
224 
225 inline int test_override_cache(std::shared_ptr<test_override_cache_helper> const &instance) {
226  return instance->func();
227 }
228 
229 // Forward declaration (so that we can put the main tests here; the inherited virtual approaches
230 // are rather long).
231 void initialize_inherited_virtuals(py::module_ &m);
232 
233 TEST_SUBMODULE(virtual_functions, m) {
234  // test_override
235  py::class_<ExampleVirt, PyExampleVirt>(m, "ExampleVirt")
236  .def(py::init<int>())
237  /* Reference original class in function definitions */
238  .def("run", &ExampleVirt::run)
239  .def("run_bool", &ExampleVirt::run_bool)
240  .def("pure_virtual", &ExampleVirt::pure_virtual);
241 
242  py::class_<NonCopyable>(m, "NonCopyable").def(py::init<int, int>());
243 
244  py::class_<Movable>(m, "Movable").def(py::init<int, int>());
245 
246  // test_move_support
247 #if !defined(__INTEL_COMPILER) && !defined(__CUDACC__) && !defined(__PGIC__)
248  py::class_<NCVirt, NCVirtTrampoline>(m, "NCVirt")
249  .def(py::init<>())
250  .def("get_noncopyable", &NCVirt::get_noncopyable)
251  .def("get_movable", &NCVirt::get_movable)
252  .def("print_nc", &NCVirt::print_nc)
253  .def("print_movable", &NCVirt::print_movable);
254 #endif
255 
256  m.def("runExampleVirt", [](ExampleVirt *ex, int value) { return ex->run(value); });
257  m.def("runExampleVirtBool", [](ExampleVirt *ex) { return ex->run_bool(); });
258  m.def("runExampleVirtVirtual", [](ExampleVirt *ex) { ex->pure_virtual(); });
259 
260  m.def("cstats_debug", &ConstructorStats::get<ExampleVirt>);
262 
263  // test_alias_delay_initialization1
264  // don't invoke Python dispatch classes by default when instantiating C++ classes
265  // that were not extended on the Python side
266  struct A {
267  A() = default;
268  A(const A &) = delete;
269  virtual ~A() = default;
270  virtual void f() { py::print("A.f()"); }
271  };
272 
273  struct PyA : A {
274  PyA() { py::print("PyA.PyA()"); }
275  PyA(const PyA &) = delete;
276  ~PyA() override { py::print("PyA.~PyA()"); }
277 
278  void f() override {
279  py::print("PyA.f()");
280  // This convolution just gives a `void`, but tests that PYBIND11_TYPE() works to
281  // protect a type containing a ,
283  }
284  };
285 
286  py::class_<A, PyA>(m, "A").def(py::init<>()).def("f", &A::f);
287 
288  m.def("call_f", [](A *a) { a->f(); });
289 
290  // test_alias_delay_initialization2
291  // ... unless we explicitly request it, as in this example:
292  struct A2 {
293  A2() = default;
294  A2(const A2 &) = delete;
295  virtual ~A2() = default;
296  virtual void f() { py::print("A2.f()"); }
297  };
298 
299  struct PyA2 : A2 {
300  PyA2() { py::print("PyA2.PyA2()"); }
301  PyA2(const PyA2 &) = delete;
302  ~PyA2() override { py::print("PyA2.~PyA2()"); }
303  void f() override {
304  py::print("PyA2.f()");
305  PYBIND11_OVERRIDE(void, A2, f);
306  }
307  };
308 
309  py::class_<A2, PyA2>(m, "A2")
310  .def(py::init_alias<>())
311  .def(py::init([](int) { return new PyA2(); }))
312  .def("f", &A2::f);
313 
314  m.def("call_f", [](A2 *a2) { a2->f(); });
315 
316  // test_dispatch_issue
317  // #159: virtual function dispatch has problems with similar-named functions
318  py::class_<Base, DispatchIssue>(m, "DispatchIssue")
319  .def(py::init<>())
320  .def("dispatch", &Base::dispatch);
321 
322  m.def("dispatch_issue_go", [](const Base *b) { return b->dispatch(); });
323 
324  // test_recursive_dispatch_issue
325  // #3357: Recursive dispatch fails to find python function override
326  pybind11::class_<AdderBase, Adder>(m, "Adder")
327  .def(pybind11::init<>())
328  .def("__call__", &AdderBase::operator());
329 
330  pybind11::class_<AdderBase::Data>(m, "Data").def(pybind11::init<>());
331 
332  m.def("add2",
333  [](const AdderBase::Data &first,
334  const AdderBase::Data &second,
335  const AdderBase &adder,
336  const AdderBase::DataVisitor &visitor) { adder(first, second, visitor); });
337 
338  m.def("add3",
339  [](const AdderBase::Data &first,
340  const AdderBase::Data &second,
341  const AdderBase::Data &third,
342  const AdderBase &adder,
343  const AdderBase::DataVisitor &visitor) {
344  adder(first, second, [&](const AdderBase::Data &first_plus_second) {
345  // NOLINTNEXTLINE(readability-suspicious-call-argument)
346  adder(first_plus_second, third, visitor);
347  });
348  });
349 
350  // test_override_ref
351  // #392/397: overriding reference-returning functions
352  class OverrideTest {
353  public:
354  struct A {
355  std::string value = "hi";
356  };
357  std::string v;
358  A a;
359  explicit OverrideTest(const std::string &v) : v{v} {}
360  OverrideTest() = default;
361  OverrideTest(const OverrideTest &) = delete;
362  virtual std::string str_value() { return v; }
363  virtual std::string &str_ref() { return v; }
364  virtual A A_value() { return a; }
365  virtual A &A_ref() { return a; }
366  virtual ~OverrideTest() = default;
367  };
368 
369  class PyOverrideTest : public OverrideTest {
370  public:
371  using OverrideTest::OverrideTest;
372  std::string str_value() override {
373  PYBIND11_OVERRIDE(std::string, OverrideTest, str_value);
374  }
375  // Not allowed (enabling the below should hit a static_assert failure): we can't get a
376  // reference to a python numeric value, since we only copy values in the numeric type
377  // caster:
378 #ifdef PYBIND11_NEVER_DEFINED_EVER
379  std::string &str_ref() override {
380  PYBIND11_OVERRIDE(std::string &, OverrideTest, str_ref);
381  }
382 #endif
383  // But we can work around it like this:
384  private:
385  std::string _tmp;
386  std::string str_ref_helper() { PYBIND11_OVERRIDE(std::string, OverrideTest, str_ref); }
387 
388  public:
389  std::string &str_ref() override { return _tmp = str_ref_helper(); }
390 
391  A A_value() override { PYBIND11_OVERRIDE(A, OverrideTest, A_value); }
392  A &A_ref() override { PYBIND11_OVERRIDE(A &, OverrideTest, A_ref); }
393  };
394 
395  py::class_<OverrideTest::A>(m, "OverrideTest_A")
396  .def_readwrite("value", &OverrideTest::A::value);
397  py::class_<OverrideTest, PyOverrideTest>(m, "OverrideTest")
398  .def(py::init<const std::string &>())
399  .def("str_value", &OverrideTest::str_value)
400 #ifdef PYBIND11_NEVER_DEFINED_EVER
401  .def("str_ref", &OverrideTest::str_ref)
402 #endif
403  .def("A_value", &OverrideTest::A_value)
404  .def("A_ref", &OverrideTest::A_ref);
405 
406  py::class_<test_override_cache_helper,
408  std::shared_ptr<test_override_cache_helper>>(m, "test_override_cache_helper")
409  .def(py::init_alias<>())
410  .def("func", &test_override_cache_helper::func);
411 
412  m.def("test_override_cache", test_override_cache);
413 }
414 
415 // Inheriting virtual methods. We do two versions here: the repeat-everything version and the
416 // templated trampoline versions mentioned in docs/advanced.rst.
417 //
418 // These base classes are exactly the same, but we technically need distinct
419 // classes for this example code because we need to be able to bind them
420 // properly (pybind11, sensibly, doesn't allow us to bind the same C++ class to
421 // multiple python classes).
422 class A_Repeat {
423 #define A_METHODS \
424 public: \
425  virtual int unlucky_number() = 0; \
426  virtual std::string say_something(unsigned times) { \
427  std::string s = ""; \
428  for (unsigned i = 0; i < times; ++i) \
429  s += "hi"; \
430  return s; \
431  } \
432  std::string say_everything() { \
433  return say_something(1) + " " + std::to_string(unlucky_number()); \
434  }
435  A_METHODS
436  A_Repeat() = default;
437  A_Repeat(const A_Repeat &) = delete;
438  virtual ~A_Repeat() = default;
439 };
440 class B_Repeat : public A_Repeat {
441 #define B_METHODS \
442 public: \
443  int unlucky_number() override { return 13; } \
444  std::string say_something(unsigned times) override { \
445  return "B says hi " + std::to_string(times) + " times"; \
446  } \
447  virtual double lucky_number() { return 7.0; }
448  B_METHODS
449 };
450 class C_Repeat : public B_Repeat {
451 #define C_METHODS \
452 public: \
453  int unlucky_number() override { return 4444; } \
454  double lucky_number() override { return 888; }
455  C_METHODS
456 };
457 class D_Repeat : public C_Repeat {
458 #define D_METHODS // Nothing overridden.
459  D_METHODS
460 };
461 
462 // Base classes for templated inheritance trampolines. Identical to the repeat-everything version:
463 class A_Tpl {
465  A_Tpl() = default;
466  A_Tpl(const A_Tpl &) = delete;
467  virtual ~A_Tpl() = default;
468 };
469 class B_Tpl : public A_Tpl {
470  B_METHODS
471 };
472 class C_Tpl : public B_Tpl {
473  C_METHODS
474 };
475 class D_Tpl : public C_Tpl {
476  D_METHODS
477 };
478 
479 // Inheritance approach 1: each trampoline gets every virtual method (11 in total)
480 class PyA_Repeat : public A_Repeat {
481 public:
482  using A_Repeat::A_Repeat;
483  int unlucky_number() override { PYBIND11_OVERRIDE_PURE(int, A_Repeat, unlucky_number, ); }
484  std::string say_something(unsigned times) override {
485  PYBIND11_OVERRIDE(std::string, A_Repeat, say_something, times);
486  }
487 };
488 class PyB_Repeat : public B_Repeat {
489 public:
490  using B_Repeat::B_Repeat;
491  int unlucky_number() override { PYBIND11_OVERRIDE(int, B_Repeat, unlucky_number, ); }
492  std::string say_something(unsigned times) override {
493  PYBIND11_OVERRIDE(std::string, B_Repeat, say_something, times);
494  }
495  double lucky_number() override { PYBIND11_OVERRIDE(double, B_Repeat, lucky_number, ); }
496 };
497 class PyC_Repeat : public C_Repeat {
498 public:
499  using C_Repeat::C_Repeat;
500  int unlucky_number() override { PYBIND11_OVERRIDE(int, C_Repeat, unlucky_number, ); }
501  std::string say_something(unsigned times) override {
502  PYBIND11_OVERRIDE(std::string, C_Repeat, say_something, times);
503  }
504  double lucky_number() override { PYBIND11_OVERRIDE(double, C_Repeat, lucky_number, ); }
505 };
506 class PyD_Repeat : public D_Repeat {
507 public:
508  using D_Repeat::D_Repeat;
509  int unlucky_number() override { PYBIND11_OVERRIDE(int, D_Repeat, unlucky_number, ); }
510  std::string say_something(unsigned times) override {
511  PYBIND11_OVERRIDE(std::string, D_Repeat, say_something, times);
512  }
513  double lucky_number() override { PYBIND11_OVERRIDE(double, D_Repeat, lucky_number, ); }
514 };
515 
516 // Inheritance approach 2: templated trampoline classes.
517 //
518 // Advantages:
519 // - we have only 2 (template) class and 4 method declarations (one per virtual method, plus one
520 // for any override of a pure virtual method), versus 4 classes and 6 methods (MI) or 4 classes
521 // and 11 methods (repeat).
522 // - Compared to MI, we also don't have to change the non-trampoline inheritance to virtual, and
523 // can properly inherit constructors.
524 //
525 // Disadvantage:
526 // - the compiler must still generate and compile 14 different methods (more, even, than the 11
527 // required for the repeat approach) instead of the 6 required for MI. (If there was no pure
528 // method (or no pure method override), the number would drop down to the same 11 as the repeat
529 // approach).
530 template <class Base = A_Tpl>
531 class PyA_Tpl : public Base {
532 public:
533  using Base::Base; // Inherit constructors
534  int unlucky_number() override { PYBIND11_OVERRIDE_PURE(int, Base, unlucky_number, ); }
535  std::string say_something(unsigned times) override {
536  PYBIND11_OVERRIDE(std::string, Base, say_something, times);
537  }
538 };
539 template <class Base = B_Tpl>
540 class PyB_Tpl : public PyA_Tpl<Base> {
541 public:
542  using PyA_Tpl<Base>::PyA_Tpl; // Inherit constructors (via PyA_Tpl's inherited constructors)
543  // NOLINTNEXTLINE(bugprone-parent-virtual-call)
544  int unlucky_number() override { PYBIND11_OVERRIDE(int, Base, unlucky_number, ); }
545  double lucky_number() override { PYBIND11_OVERRIDE(double, Base, lucky_number, ); }
546 };
547 // Since C_Tpl and D_Tpl don't declare any new virtual methods, we don't actually need these
548 // (we can use PyB_Tpl<C_Tpl> and PyB_Tpl<D_Tpl> for the trampoline classes instead):
549 /*
550 template <class Base = C_Tpl> class PyC_Tpl : public PyB_Tpl<Base> {
551 public:
552  using PyB_Tpl<Base>::PyB_Tpl;
553 };
554 template <class Base = D_Tpl> class PyD_Tpl : public PyC_Tpl<Base> {
555 public:
556  using PyC_Tpl<Base>::PyC_Tpl;
557 };
558 */
559 
560 void initialize_inherited_virtuals(py::module_ &m) {
561  // test_inherited_virtuals
562 
563  // Method 1: repeat
564  py::class_<A_Repeat, PyA_Repeat>(m, "A_Repeat")
565  .def(py::init<>())
566  .def("unlucky_number", &A_Repeat::unlucky_number)
567  .def("say_something", &A_Repeat::say_something)
568  .def("say_everything", &A_Repeat::say_everything);
569  py::class_<B_Repeat, A_Repeat, PyB_Repeat>(m, "B_Repeat")
570  .def(py::init<>())
571  .def("lucky_number", &B_Repeat::lucky_number);
572  py::class_<C_Repeat, B_Repeat, PyC_Repeat>(m, "C_Repeat").def(py::init<>());
573  py::class_<D_Repeat, C_Repeat, PyD_Repeat>(m, "D_Repeat").def(py::init<>());
574 
575  // test_
576  // Method 2: Templated trampolines
577  py::class_<A_Tpl, PyA_Tpl<>>(m, "A_Tpl")
578  .def(py::init<>())
579  .def("unlucky_number", &A_Tpl::unlucky_number)
580  .def("say_something", &A_Tpl::say_something)
581  .def("say_everything", &A_Tpl::say_everything);
582  py::class_<B_Tpl, A_Tpl, PyB_Tpl<>>(m, "B_Tpl")
583  .def(py::init<>())
584  .def("lucky_number", &B_Tpl::lucky_number);
585  py::class_<C_Tpl, B_Tpl, PyB_Tpl<C_Tpl>>(m, "C_Tpl").def(py::init<>());
586  py::class_<D_Tpl, C_Tpl, PyB_Tpl<D_Tpl>>(m, "D_Tpl").def(py::init<>());
587 
588  // Fix issue #1454 (crash when acquiring/releasing GIL on another thread in Python 2.7)
589  m.def("test_gil", &test_gil);
590  m.def("test_gil_from_thread", &test_gil_from_thread);
591 };
static void test_gil()
Matrix3f m
std::string say_something(unsigned times) override
std::string dispatch() const override
std::unique_ptr< int > value
int unlucky_number() override
virtual std::string dispatch() const =0
double lucky_number() override
virtual void pure_virtual()=0
#define A_METHODS
Scalar * b
Definition: benchVecAdd.cpp:17
std::string print_movable(int a, int b)
#define D_METHODS
int unlucky_number() override
void print_destroyed(T *inst, Values &&...values)
NonCopyable(int a, int b)
void operator()(const Data &first, const Data &second, const DataVisitor &visitor) const override
const std::string str2
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
#define PYBIND11_OVERRIDE_PURE_NAME(ret_type, cname, name, fn,...)
Definition: pybind11.h:2792
void print_copy_created(T *inst, Values &&...values)
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
Movable get_movable(int a, int b) override
The &#39;instance&#39; type which needs to be standard layout (need to be able to use &#39;offsetof&#39;) ...
double lucky_number() override
static void test_gil_from_thread()
virtual Movable get_movable(int a, int b)=0
std::string say_something(unsigned times) override
std::string say_something(unsigned times) override
virtual const std::string * get_string2()
int test_override_cache(std::shared_ptr< test_override_cache_helper > const &instance)
int run(int value) override
NonCopyable(NonCopyable &&o) noexcept
int unlucky_number() override
#define B_METHODS
virtual bool run_bool()=0
#define C_METHODS
const std::string str1
ExampleVirt(ExampleVirt &&e) noexcept
TEST_SUBMODULE(virtual_functions, m)
bool run_bool() override
Array< int, Dynamic, 1 > v
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
double lucky_number() override
void pure_virtual() override
A_METHODS A_Repeat()=default
#define PYBIND11_OVERRIDE(ret_type, cname, fn,...)
Definition: pybind11.h:2824
virtual NonCopyable get_noncopyable(int a, int b)
int unlucky_number() override
std::string say_something(unsigned times) override
Point2 a2
Definition: testPose2.cpp:770
double lucky_number() override
void print_created(T *inst, Values &&...values)
ExampleVirt(const ExampleVirt &e)
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:1882
Movable(const Movable &m)
std::string print_nc(int a, int b)
#define PYBIND11_OVERRIDE_PURE(ret_type, cname, fn,...)
Definition: pybind11.h:2831
int unlucky_number() override
Base()=default
const std::string * get_string2() override
virtual const std::string & get_string1()
const std::string & get_string1() override
std::string say_something(unsigned times) override
std::string get_value() const
void print_move_created(T *inst, Values &&...values)
Movable(int a, int b)
std::string get_value() const
void initialize_inherited_virtuals(py::module_ &m)
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
NonCopyable get_noncopyable(int a, int b) override
int unlucky_number() override
#define PYBIND11_TYPE(...)
Definition: cast.h:1663
std::function< void(const Data &)> DataVisitor
Point2 t(10, 10)
Movable(Movable &&m) noexcept
virtual int run(int value)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:46