mirror of https://github.com/swig/swig
Default constructor detection fix for templated constructors
Don't generate a default constructor wrapper when a class has a templated constructor, as there isn't actually an implied default constructor. For example: struct TConstructor3 { template<typename T> TConstructor3(T val) {} }; Previously wrappers were generated for a non-existent default constructor which failed to compile.
This commit is contained in:
parent
2ff9da0ce6
commit
c9d79386d9
|
@ -7,6 +7,18 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.2.0 (in progress)
|
||||
===========================
|
||||
|
||||
2023-07-21: wsfulton
|
||||
Don't generate a default constructor wrapper when a class has a
|
||||
templated constructor, as there isn't actually an implied default
|
||||
constructor. For example:
|
||||
|
||||
struct TConstructor3 {
|
||||
template<typename T> TConstructor3(T val) {}
|
||||
};
|
||||
|
||||
Previously wrappers were generated for a non-existent default
|
||||
constructor which failed to compile.
|
||||
|
||||
2023-07-15: wsfulton
|
||||
C++11 using declarations for inheriting constructors has now been
|
||||
extended to support the directors feature.
|
||||
|
|
|
@ -16,6 +16,20 @@ public:
|
|||
~TConstructor2() {}
|
||||
};
|
||||
|
||||
class TConstructor3 {
|
||||
public:
|
||||
// No implicit default constructor available
|
||||
template<typename T> TConstructor3(T val) {}
|
||||
~TConstructor3() {}
|
||||
};
|
||||
|
||||
class TConstructor4 {
|
||||
public:
|
||||
// No constructors available from wrappers when there is no %template to instantiate templated constructor
|
||||
template<typename T> TConstructor4() {}
|
||||
~TConstructor4() {}
|
||||
};
|
||||
|
||||
template<typename T> class TClass1 {
|
||||
public:
|
||||
template<typename Y> TClass1(Y t) {}
|
||||
|
|
|
@ -1123,6 +1123,15 @@ Allocate():
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int templateDeclaration(Node *n) {
|
||||
String *ttype = Getattr(n, "templatetype");
|
||||
if (Equal(ttype, "constructor")) {
|
||||
// Templated constructors need to be taken account of even if not instantiated with %template
|
||||
constructorDeclaration(n);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int constructorDeclaration(Node *n) {
|
||||
if (!inclass)
|
||||
return SWIG_OK;
|
||||
|
|
|
@ -1497,7 +1497,7 @@ int SwigType_type(const SwigType *t) {
|
|||
*
|
||||
* This is the default behavior unless:
|
||||
*
|
||||
* 1.- swig detects a default_constructor and 'setallocate:default_constructor'
|
||||
* 1.- swig detects a default_constructor and 'allocate:default_constructor'
|
||||
* attribute.
|
||||
*
|
||||
* 2.- swig doesn't mark 'type' as non-assignable.
|
||||
|
|
Loading…
Reference in New Issue