mirror of https://github.com/swig/swig
C++11 using declarations for inheriting implicit base templated constructors
Testcase - compiles given previous commit, but needs more work!
This commit is contained in:
parent
c9d79386d9
commit
525426911c
|
@ -5,4 +5,8 @@
|
||||||
|
|
||||||
%feature("director");
|
%feature("director");
|
||||||
|
|
||||||
|
%warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) TemplateConstructor1Derived;
|
||||||
|
%warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) TemplateConstructor2Base;
|
||||||
|
%warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) TemplateConstructor2Derived;
|
||||||
|
|
||||||
%include "cpp11_using_constructor.i"
|
%include "cpp11_using_constructor.i"
|
||||||
|
|
|
@ -423,7 +423,6 @@ struct TemplPublicBase6 {
|
||||||
#endif
|
#endif
|
||||||
virtual void meth() {}
|
virtual void meth() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%template(TemplPublicBase1Int) TemplPublicBase1<int>;
|
%template(TemplPublicBase1Int) TemplPublicBase1<int>;
|
||||||
|
@ -472,3 +471,37 @@ struct TemplPublicDerived6 : TemplPublicBase6<T> {
|
||||||
%template(TemplPublicDerived4Int) TemplPublicDerived4<int>;
|
%template(TemplPublicDerived4Int) TemplPublicDerived4<int>;
|
||||||
%template(TemplPublicDerived5Int) TemplPublicDerived5<int>;
|
%template(TemplPublicDerived5Int) TemplPublicDerived5<int>;
|
||||||
%template(TemplPublicDerived6Int) TemplPublicDerived6<int>;
|
%template(TemplPublicDerived6Int) TemplPublicDerived6<int>;
|
||||||
|
|
||||||
|
|
||||||
|
// Templated constructors
|
||||||
|
%inline %{
|
||||||
|
struct TemplateConstructor1Base {
|
||||||
|
virtual ~TemplateConstructor1Base() {}
|
||||||
|
// No implicit constructor
|
||||||
|
template <typename T> TemplateConstructor1Base(const T &t, const char *s) {}
|
||||||
|
virtual void meth() {}
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
%template(TemplateConstructor1Base) TemplateConstructor1Base::TemplateConstructor1Base<int>;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct TemplateConstructor1Derived : TemplateConstructor1Base {
|
||||||
|
using TemplateConstructor1Base::TemplateConstructor1Base;
|
||||||
|
using TemplateConstructor1Base::meth;
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
// TODO: Missing constructors, below probably ought to work using instantiation as follows:
|
||||||
|
//%template(TemplateConstructor1Derived) TemplateConstructor1Derived::TemplateConstructor1Derived<int>;
|
||||||
|
|
||||||
|
%{
|
||||||
|
void tester() {
|
||||||
|
TemplateConstructor1Derived tc = TemplateConstructor1Derived(123, "hi");
|
||||||
|
tc.meth();
|
||||||
|
// Note not valid c++:
|
||||||
|
// TemplateConstructor1Derived tc2 = TemplateConstructor1Derived::TemplateConstructor1Derived<int>(123, "hi");
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
// Note that templated methods also not working with using declarations for inheriting from base templated methods
|
||||||
|
|
|
@ -127,5 +127,10 @@ public class cpp11_using_constructor_runme {
|
||||||
new TemplPublicDerived5Int().meth();
|
new TemplPublicDerived5Int().meth();
|
||||||
new TemplPublicDerived6Int(0, "hi").meth();
|
new TemplPublicDerived6Int(0, "hi").meth();
|
||||||
new TemplPublicDerived6Int().meth();
|
new TemplPublicDerived6Int().meth();
|
||||||
|
|
||||||
|
// Templated constructors
|
||||||
|
new TemplateConstructor1Base(0, "hi").meth();
|
||||||
|
// TODO: missing constructor...
|
||||||
|
// new TemplateConstructor1Derived(0, "hi").meth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue