blob: 80ebe4ce21f68cf304858f93845c58ddd5b54f94 [file] [log] [blame]
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -04001/*
Dean Moldovana0c1ccf2016-08-12 13:50:00 +02002 tests/test_virtual_functions.cpp -- overriding virtual functions from Python
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -04003
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
Dean Moldovana0c1ccf2016-08-12 13:50:00 +020010#include "pybind11_tests.h"
11#include "constructor_stats.h"
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040012#include <pybind11/functional.h>
13
14/* This is an example class that we'll want to be able to extend from Python */
15class ExampleVirt {
16public:
Jason Rhinelander3f589372016-08-07 13:05:26 -040017 ExampleVirt(int state) : state(state) { print_created(this, state); }
18 ExampleVirt(const ExampleVirt &e) : state(e.state) { print_copy_created(this); }
19 ExampleVirt(ExampleVirt &&e) : state(e.state) { print_move_created(this); e.state = 0; }
20 ~ExampleVirt() { print_destroyed(this); }
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040021
22 virtual int run(int value) {
Dean Moldovan81511be2016-09-07 00:50:10 +020023 py::print("Original implementation of "
Jason Rhinelander7dfb9322016-09-08 14:49:43 -040024 "ExampleVirt::run(state={}, value={}, str1={}, str2={})"_s.format(state, value, get_string1(), *get_string2()));
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040025 return state + value;
26 }
27
28 virtual bool run_bool() = 0;
29 virtual void pure_virtual() = 0;
Jason Rhinelander7dfb9322016-09-08 14:49:43 -040030
31 // Returning a reference/pointer to a type converted from python (numbers, strings, etc.) is a
32 // bit trickier, because the actual int& or std::string& or whatever only exists temporarily, so
33 // we have to handle it specially in the trampoline class (see below).
34 virtual const std::string &get_string1() { return str1; }
35 virtual const std::string *get_string2() { return &str2; }
36
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040037private:
38 int state;
Jason Rhinelander7dfb9322016-09-08 14:49:43 -040039 const std::string str1{"default1"}, str2{"default2"};
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040040};
41
42/* This is a wrapper class that must be generated */
43class PyExampleVirt : public ExampleVirt {
44public:
45 using ExampleVirt::ExampleVirt; /* Inherit constructors */
46
Jason Rhinelander116d37c2016-09-08 14:47:05 -040047 int run(int value) override {
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040048 /* Generate wrapping code that enables native function overloading */
49 PYBIND11_OVERLOAD(
50 int, /* Return type */
51 ExampleVirt, /* Parent class */
52 run, /* Name of function */
53 value /* Argument(s) */
54 );
55 }
56
Jason Rhinelander116d37c2016-09-08 14:47:05 -040057 bool run_bool() override {
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040058 PYBIND11_OVERLOAD_PURE(
59 bool, /* Return type */
60 ExampleVirt, /* Parent class */
61 run_bool, /* Name of function */
62 /* This function has no arguments. The trailing comma
63 in the previous line is needed for some compilers */
64 );
65 }
66
Jason Rhinelander116d37c2016-09-08 14:47:05 -040067 void pure_virtual() override {
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040068 PYBIND11_OVERLOAD_PURE(
69 void, /* Return type */
70 ExampleVirt, /* Parent class */
71 pure_virtual, /* Name of function */
72 /* This function has no arguments. The trailing comma
73 in the previous line is needed for some compilers */
74 );
75 }
Jason Rhinelander7dfb9322016-09-08 14:49:43 -040076
77 // We can return reference types for compatibility with C++ virtual interfaces that do so, but
78 // note they have some significant limitations (see the documentation).
79 const std::string &get_string1() override {
80 PYBIND11_OVERLOAD(
81 const std::string &, /* Return type */
82 ExampleVirt, /* Parent class */
83 get_string1, /* Name of function */
84 /* (no arguments) */
85 );
86 }
87
88 const std::string *get_string2() override {
89 PYBIND11_OVERLOAD(
90 const std::string *, /* Return type */
91 ExampleVirt, /* Parent class */
92 get_string2, /* Name of function */
93 /* (no arguments) */
94 );
95 }
96
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040097};
98
Jason Rhinelandered148792016-07-21 21:31:05 -040099class NonCopyable {
100public:
Jason Rhinelander3f589372016-08-07 13:05:26 -0400101 NonCopyable(int a, int b) : value{new int(a*b)} { print_created(this, a, b); }
102 NonCopyable(NonCopyable &&o) { value = std::move(o.value); print_move_created(this); }
Jason Rhinelandered148792016-07-21 21:31:05 -0400103 NonCopyable(const NonCopyable &) = delete;
104 NonCopyable() = delete;
105 void operator=(const NonCopyable &) = delete;
106 void operator=(NonCopyable &&) = delete;
107 std::string get_value() const {
108 if (value) return std::to_string(*value); else return "(null)";
109 }
Jason Rhinelander3f589372016-08-07 13:05:26 -0400110 ~NonCopyable() { print_destroyed(this); }
Jason Rhinelandered148792016-07-21 21:31:05 -0400111
112private:
113 std::unique_ptr<int> value;
114};
115
116// This is like the above, but is both copy and movable. In effect this means it should get moved
117// when it is not referenced elsewhere, but copied if it is still referenced.
118class Movable {
119public:
Jason Rhinelander3f589372016-08-07 13:05:26 -0400120 Movable(int a, int b) : value{a+b} { print_created(this, a, b); }
121 Movable(const Movable &m) { value = m.value; print_copy_created(this); }
122 Movable(Movable &&m) { value = std::move(m.value); print_move_created(this); }
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200123 std::string get_value() const { return std::to_string(value); }
Jason Rhinelander3f589372016-08-07 13:05:26 -0400124 ~Movable() { print_destroyed(this); }
Jason Rhinelandered148792016-07-21 21:31:05 -0400125private:
126 int value;
127};
128
129class NCVirt {
130public:
131 virtual NonCopyable get_noncopyable(int a, int b) { return NonCopyable(a, b); }
132 virtual Movable get_movable(int a, int b) = 0;
133
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200134 std::string print_nc(int a, int b) { return get_noncopyable(a, b).get_value(); }
135 std::string print_movable(int a, int b) { return get_movable(a, b).get_value(); }
Jason Rhinelandered148792016-07-21 21:31:05 -0400136};
137class NCVirtTrampoline : public NCVirt {
Wenzel Jakob1ffce742016-08-25 01:43:33 +0200138#if !defined(__INTEL_COMPILER)
Jason Rhinelander116d37c2016-09-08 14:47:05 -0400139 NonCopyable get_noncopyable(int a, int b) override {
Jason Rhinelandered148792016-07-21 21:31:05 -0400140 PYBIND11_OVERLOAD(NonCopyable, NCVirt, get_noncopyable, a, b);
141 }
Wenzel Jakob1ffce742016-08-25 01:43:33 +0200142#endif
Jason Rhinelander116d37c2016-09-08 14:47:05 -0400143 Movable get_movable(int a, int b) override {
Jason Rhinelandered148792016-07-21 21:31:05 -0400144 PYBIND11_OVERLOAD_PURE(Movable, NCVirt, get_movable, a, b);
145 }
146};
147
Jason Rhinelander391c7542017-07-25 16:47:36 -0400148struct Base {
149 /* for some reason MSVC2015 can't compile this if the function is pure virtual */
150 virtual std::string dispatch() const { return {}; };
151};
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -0400152
Jason Rhinelander391c7542017-07-25 16:47:36 -0400153struct DispatchIssue : Base {
154 virtual std::string dispatch() const {
155 PYBIND11_OVERLOAD_PURE(std::string, Base, dispatch, /* no arguments */);
156 }
157};
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -0400158
Jason Rhinelander391c7542017-07-25 16:47:36 -0400159// Forward declaration (so that we can put the main tests here; the inherited virtual approaches are
160// rather long).
161void initialize_inherited_virtuals(py::module &m);
162
163TEST_SUBMODULE(virtual_functions, m) {
164 // test_override
165 py::class_<ExampleVirt, PyExampleVirt>(m, "ExampleVirt")
166 .def(py::init<int>())
167 /* Reference original class in function definitions */
168 .def("run", &ExampleVirt::run)
169 .def("run_bool", &ExampleVirt::run_bool)
170 .def("pure_virtual", &ExampleVirt::pure_virtual);
171
172 py::class_<NonCopyable>(m, "NonCopyable")
173 .def(py::init<int, int>());
174
175 py::class_<Movable>(m, "Movable")
176 .def(py::init<int, int>());
177
178 // test_move_support
179#if !defined(__INTEL_COMPILER)
180 py::class_<NCVirt, NCVirtTrampoline>(m, "NCVirt")
181 .def(py::init<>())
182 .def("get_noncopyable", &NCVirt::get_noncopyable)
183 .def("get_movable", &NCVirt::get_movable)
184 .def("print_nc", &NCVirt::print_nc)
185 .def("print_movable", &NCVirt::print_movable);
186#endif
187
188 m.def("runExampleVirt", [](ExampleVirt *ex, int value) { return ex->run(value); });
189 m.def("runExampleVirtBool", [](ExampleVirt* ex) { return ex->run_bool(); });
190 m.def("runExampleVirtVirtual", [](ExampleVirt *ex) { ex->pure_virtual(); });
191
192 m.def("cstats_debug", &ConstructorStats::get<ExampleVirt>);
193 initialize_inherited_virtuals(m);
194
195 // test_alias_delay_initialization1
196 // don't invoke Python dispatch classes by default when instantiating C++ classes
197 // that were not extended on the Python side
198 struct A {
199 virtual ~A() {}
200 virtual void f() { py::print("A.f()"); }
201 };
202
203 struct PyA : A {
204 PyA() { py::print("PyA.PyA()"); }
205 ~PyA() { py::print("PyA.~PyA()"); }
206
207 void f() override {
208 py::print("PyA.f()");
209 PYBIND11_OVERLOAD(void, A, f);
210 }
211 };
212
213 py::class_<A, PyA>(m, "A")
214 .def(py::init<>())
215 .def("f", &A::f);
216
217 m.def("call_f", [](A *a) { a->f(); });
218
219 // test_alias_delay_initialization2
220 // ... unless we explicitly request it, as in this example:
221 struct A2 {
222 virtual ~A2() {}
223 virtual void f() { py::print("A2.f()"); }
224 };
225
226 struct PyA2 : A2 {
227 PyA2() { py::print("PyA2.PyA2()"); }
228 ~PyA2() { py::print("PyA2.~PyA2()"); }
229 void f() override {
230 py::print("PyA2.f()");
231 PYBIND11_OVERLOAD(void, A2, f);
232 }
233 };
234
235 py::class_<A2, PyA2>(m, "A2")
236 .def(py::init_alias<>())
Jason Rhinelander464d9892017-06-12 21:52:48 -0400237 .def(py::init([](int) { return new PyA2(); }))
Jason Rhinelander391c7542017-07-25 16:47:36 -0400238 .def("f", &A2::f);
239
240 m.def("call_f", [](A2 *a2) { a2->f(); });
241
242 // test_dispatch_issue
243 // #159: virtual function dispatch has problems with similar-named functions
244 py::class_<Base, DispatchIssue>(m, "DispatchIssue")
245 .def(py::init<>())
246 .def("dispatch", &Base::dispatch);
247
248 m.def("dispatch_issue_go", [](const Base * b) { return b->dispatch(); });
249
250 // test_override_ref
251 // #392/397: overridding reference-returning functions
252 class OverrideTest {
253 public:
254 struct A { std::string value = "hi"; };
255 std::string v;
256 A a;
257 explicit OverrideTest(const std::string &v) : v{v} {}
258 virtual std::string str_value() { return v; }
259 virtual std::string &str_ref() { return v; }
260 virtual A A_value() { return a; }
261 virtual A &A_ref() { return a; }
262 };
263
264 class PyOverrideTest : public OverrideTest {
265 public:
266 using OverrideTest::OverrideTest;
267 std::string str_value() override { PYBIND11_OVERLOAD(std::string, OverrideTest, str_value); }
268 // Not allowed (uncommenting should hit a static_assert failure): we can't get a reference
269 // to a python numeric value, since we only copy values in the numeric type caster:
270// std::string &str_ref() override { PYBIND11_OVERLOAD(std::string &, OverrideTest, str_ref); }
271 // But we can work around it like this:
272 private:
273 std::string _tmp;
274 std::string str_ref_helper() { PYBIND11_OVERLOAD(std::string, OverrideTest, str_ref); }
275 public:
276 std::string &str_ref() override { return _tmp = str_ref_helper(); }
277
278 A A_value() override { PYBIND11_OVERLOAD(A, OverrideTest, A_value); }
279 A &A_ref() override { PYBIND11_OVERLOAD(A &, OverrideTest, A_ref); }
280 };
281
282 py::class_<OverrideTest::A>(m, "OverrideTest_A")
283 .def_readwrite("value", &OverrideTest::A::value);
284 py::class_<OverrideTest, PyOverrideTest>(m, "OverrideTest")
285 .def(py::init<const std::string &>())
286 .def("str_value", &OverrideTest::str_value)
287// .def("str_ref", &OverrideTest::str_ref)
288 .def("A_value", &OverrideTest::A_value)
289 .def("A_ref", &OverrideTest::A_ref);
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -0400290}
291
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400292
Jason Rhinelanderd6c365b2016-08-05 17:44:28 -0400293// Inheriting virtual methods. We do two versions here: the repeat-everything version and the
294// templated trampoline versions mentioned in docs/advanced.rst.
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400295//
Jason Rhinelanderd6c365b2016-08-05 17:44:28 -0400296// These base classes are exactly the same, but we technically need distinct
297// classes for this example code because we need to be able to bind them
298// properly (pybind11, sensibly, doesn't allow us to bind the same C++ class to
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400299// multiple python classes).
300class A_Repeat {
301#define A_METHODS \
302public: \
303 virtual int unlucky_number() = 0; \
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200304 virtual std::string say_something(unsigned times) { \
305 std::string s = ""; \
306 for (unsigned i = 0; i < times; ++i) \
307 s += "hi"; \
308 return s; \
Jason Rhinelander20978262016-08-29 18:16:46 -0400309 } \
310 std::string say_everything() { \
311 return say_something(1) + " " + std::to_string(unlucky_number()); \
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400312 }
313A_METHODS
314};
315class B_Repeat : public A_Repeat {
316#define B_METHODS \
317public: \
318 int unlucky_number() override { return 13; } \
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200319 std::string say_something(unsigned times) override { \
320 return "B says hi " + std::to_string(times) + " times"; \
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400321 } \
322 virtual double lucky_number() { return 7.0; }
323B_METHODS
324};
325class C_Repeat : public B_Repeat {
326#define C_METHODS \
327public: \
328 int unlucky_number() override { return 4444; } \
329 double lucky_number() override { return 888; }
330C_METHODS
331};
332class D_Repeat : public C_Repeat {
333#define D_METHODS // Nothing overridden.
334D_METHODS
335};
336
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400337// Base classes for templated inheritance trampolines. Identical to the repeat-everything version:
338class A_Tpl { A_METHODS };
339class B_Tpl : public A_Tpl { B_METHODS };
340class C_Tpl : public B_Tpl { C_METHODS };
341class D_Tpl : public C_Tpl { D_METHODS };
342
343
344// Inheritance approach 1: each trampoline gets every virtual method (11 in total)
345class PyA_Repeat : public A_Repeat {
346public:
347 using A_Repeat::A_Repeat;
348 int unlucky_number() override { PYBIND11_OVERLOAD_PURE(int, A_Repeat, unlucky_number, ); }
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200349 std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, A_Repeat, say_something, times); }
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400350};
351class PyB_Repeat : public B_Repeat {
352public:
353 using B_Repeat::B_Repeat;
354 int unlucky_number() override { PYBIND11_OVERLOAD(int, B_Repeat, unlucky_number, ); }
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200355 std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, B_Repeat, say_something, times); }
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400356 double lucky_number() override { PYBIND11_OVERLOAD(double, B_Repeat, lucky_number, ); }
357};
358class PyC_Repeat : public C_Repeat {
359public:
360 using C_Repeat::C_Repeat;
361 int unlucky_number() override { PYBIND11_OVERLOAD(int, C_Repeat, unlucky_number, ); }
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200362 std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, C_Repeat, say_something, times); }
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400363 double lucky_number() override { PYBIND11_OVERLOAD(double, C_Repeat, lucky_number, ); }
364};
365class PyD_Repeat : public D_Repeat {
366public:
367 using D_Repeat::D_Repeat;
368 int unlucky_number() override { PYBIND11_OVERLOAD(int, D_Repeat, unlucky_number, ); }
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200369 std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, D_Repeat, say_something, times); }
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400370 double lucky_number() override { PYBIND11_OVERLOAD(double, D_Repeat, lucky_number, ); }
371};
372
373// Inheritance approach 2: templated trampoline classes.
374//
375// Advantages:
376// - we have only 2 (template) class and 4 method declarations (one per virtual method, plus one for
377// any override of a pure virtual method), versus 4 classes and 6 methods (MI) or 4 classes and 11
378// methods (repeat).
379// - Compared to MI, we also don't have to change the non-trampoline inheritance to virtual, and can
380// properly inherit constructors.
381//
382// Disadvantage:
383// - the compiler must still generate and compile 14 different methods (more, even, than the 11
384// required for the repeat approach) instead of the 6 required for MI. (If there was no pure
385// method (or no pure method override), the number would drop down to the same 11 as the repeat
386// approach).
387template <class Base = A_Tpl>
388class PyA_Tpl : public Base {
389public:
390 using Base::Base; // Inherit constructors
391 int unlucky_number() override { PYBIND11_OVERLOAD_PURE(int, Base, unlucky_number, ); }
Dean Moldovan99dbdc12016-08-19 13:45:36 +0200392 std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, Base, say_something, times); }
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400393};
394template <class Base = B_Tpl>
395class PyB_Tpl : public PyA_Tpl<Base> {
396public:
397 using PyA_Tpl<Base>::PyA_Tpl; // Inherit constructors (via PyA_Tpl's inherited constructors)
398 int unlucky_number() override { PYBIND11_OVERLOAD(int, Base, unlucky_number, ); }
Wenzel Jakob216df0d2016-08-12 00:59:57 +0200399 double lucky_number() override { PYBIND11_OVERLOAD(double, Base, lucky_number, ); }
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400400};
401// Since C_Tpl and D_Tpl don't declare any new virtual methods, we don't actually need these (we can
402// use PyB_Tpl<C_Tpl> and PyB_Tpl<D_Tpl> for the trampoline classes instead):
403/*
404template <class Base = C_Tpl> class PyC_Tpl : public PyB_Tpl<Base> {
405public:
406 using PyB_Tpl<Base>::PyB_Tpl;
407};
408template <class Base = D_Tpl> class PyD_Tpl : public PyC_Tpl<Base> {
409public:
410 using PyC_Tpl<Base>::PyC_Tpl;
411};
412*/
413
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400414
415void initialize_inherited_virtuals(py::module &m) {
Jason Rhinelander391c7542017-07-25 16:47:36 -0400416 // test_inherited_virtuals
417
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400418 // Method 1: repeat
Jason Rhinelander5fffe202016-09-06 12:17:06 -0400419 py::class_<A_Repeat, PyA_Repeat>(m, "A_Repeat")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400420 .def(py::init<>())
421 .def("unlucky_number", &A_Repeat::unlucky_number)
Jason Rhinelander20978262016-08-29 18:16:46 -0400422 .def("say_something", &A_Repeat::say_something)
423 .def("say_everything", &A_Repeat::say_everything);
Jason Rhinelander6b52c832016-09-06 12:27:00 -0400424 py::class_<B_Repeat, A_Repeat, PyB_Repeat>(m, "B_Repeat")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400425 .def(py::init<>())
426 .def("lucky_number", &B_Repeat::lucky_number);
Jason Rhinelander6b52c832016-09-06 12:27:00 -0400427 py::class_<C_Repeat, B_Repeat, PyC_Repeat>(m, "C_Repeat")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400428 .def(py::init<>());
Jason Rhinelander6b52c832016-09-06 12:27:00 -0400429 py::class_<D_Repeat, C_Repeat, PyD_Repeat>(m, "D_Repeat")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400430 .def(py::init<>());
431
Jason Rhinelander391c7542017-07-25 16:47:36 -0400432 // test_
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400433 // Method 2: Templated trampolines
Jason Rhinelander5fffe202016-09-06 12:17:06 -0400434 py::class_<A_Tpl, PyA_Tpl<>>(m, "A_Tpl")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400435 .def(py::init<>())
436 .def("unlucky_number", &A_Tpl::unlucky_number)
Jason Rhinelander20978262016-08-29 18:16:46 -0400437 .def("say_something", &A_Tpl::say_something)
438 .def("say_everything", &A_Tpl::say_everything);
Jason Rhinelander6b52c832016-09-06 12:27:00 -0400439 py::class_<B_Tpl, A_Tpl, PyB_Tpl<>>(m, "B_Tpl")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400440 .def(py::init<>())
441 .def("lucky_number", &B_Tpl::lucky_number);
Jason Rhinelander6b52c832016-09-06 12:27:00 -0400442 py::class_<C_Tpl, B_Tpl, PyB_Tpl<C_Tpl>>(m, "C_Tpl")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400443 .def(py::init<>());
Jason Rhinelander6b52c832016-09-06 12:27:00 -0400444 py::class_<D_Tpl, C_Tpl, PyB_Tpl<D_Tpl>>(m, "D_Tpl")
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400445 .def(py::init<>());
446
Jason Rhinelander0ca96e22016-08-05 17:02:33 -0400447};