Add a polymorphic static assert when using an alias

An alias can be used for two main purposes: to override virtual methods,
and to add some extra data to a class needed for the pybind-wrapper.
Both of these absolutely require that the wrapped class be polymorphic
so that virtual dispatch and destruction, respectively, works.
This commit is contained in:
Jason Rhinelander
2017-06-12 21:48:36 -04:00
parent b4bf5ed575
commit 42e5ddc541
2 changed files with 4 additions and 1 deletions

View File

@@ -231,7 +231,7 @@ TEST_SUBMODULE(class_, m) {
bind_local<LocalExternal, 17>(m, "LocalExternal", py::module_local());
}
template <int N> class BreaksBase {};
template <int N> class BreaksBase { public: virtual ~BreaksBase() = default; };
template <int N> class BreaksTramp : public BreaksBase<N> {};
// These should all compile just fine:
typedef py::class_<BreaksBase<1>, std::unique_ptr<BreaksBase<1>>, BreaksTramp<1>> DoesntBreak1;