[PyQt] SIP template-based class with argument having default constructor as default value

Denis Rouzaud denis.rouzaud at gmail.com
Tue Jun 13 15:16:31 BST 2017

Hi all,

Title says it all ;)

I think there is an issue on how SIP handles the default value argument for
template-based classes.
SIP don't replaces the T var by the implemented  base class constructor.
See below.

Let's say I have

template <typename T>
class Base
    Base( const T &epoch = T()) : mEpoch( epoch ){}
    T mEpoch;

typedef Base< QDate > MyDate;
typedef Base< QDateTime > MyDateTime;

Here is the SIP code generated:

static void *init_type_MyDate(sipSimpleWrapper *, PyObject *sipArgs,
PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject
    MyDate *sipCpp = 0;
        const QDate& a0def = T();
        const QDate* a0 = &a0def;
        int a0State = 0;

I get an error:
use of undeclared identifier 'T'
     in   const QDate& a0def = T();

Does someone confirm?
Is there a workaround?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170613/6821d1d0/attachment.html>

More information about the PyQt mailing list