-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
If I have a director class that returns a Non-Default-Constructible type from a virtual function:
test.i:
%module(directors="1") test
%feature("director") MyDirector;
%inline
%{
class NotDefaultConstructible {
public:
NotDefaultConstructible(int) {}
};
class MyDirector {
public:
virtual ~MyDirector();
virtual NotDefaultConstructible foo() = 0;
};
%}
When I generate the python wrapper and compile the resulting test_wrap.cxx file, I get an error related to trying to default construct the object:
test_wrap.cxx: In member function ‘virtual NotDefaultConstructible SwigDirector_MyDirector::foo()’:
test_wrap.cxx:3744:27: error: no matching function for call to ‘NotDefaultConstructible::NotDefaultConstructible()’
NotDefaultConstructible c_result;
^
test_wrap.cxx:3744:27: note: candidates are:
test_wrap.cxx:3562:5: note: NotDefaultConstructible::NotDefaultConstructible(int)
NotDefaultConstructible(int) {}
^
test_wrap.cxx:3562:5: note: candidate expects 1 argument, 0 provided
test_wrap.cxx:3560:7: note: NotDefaultConstructible::NotDefaultConstructible(const NotDefaultConstructible&)
class NotDefaultConstructible {
^
test_wrap.cxx:3560:7: note: candidate expects 1 argument, 0 provided
This seems to be specific to the combination of:
- target language = python (In particular java does not exhibit the issue)
- virtual member function
- of a director class
Comparing to the code generated by changing one or more of the above parameters, it seems the more usual declaration is SwigValueWrapper< NotDefaultConstructible > c_result;
Failing to use the wrapper type seems to be the cause of the compile error.
NB Attempting to enforce this with explicit %feature("valuewrapper") NotDefaultConstructible;
and/or %nodefaultctor NotDefaultConstructible;
lines still results in the same error.
SWIG version: 3.0.12