No, the constructor is available and correct.
If this wasn't the case, the code wouldn't have compiled when I remove the templates and replace it with int.

On 2011/05/13 11:58 AM, Martin Dobias wrote:
On Fri, May 13, 2011 at 9:32 AM, GOO Creations<goocreati...@gmail.com>  wrote:
Hi all

I'm currently writing C++ code that I want to use via Python with SIP. The
following is a skeleton for my code:

template<class T>
class MyClass
{
     MyClass(QString s);
     T* calculate();
}

class B
{
     B();
     void doStuff();
}

void B::doStuff()
{
     MyClass<int>  var("");
     int *var2 = var.calculate();
}

The only class I've included in my SIP file is class B (and not class A).
Everything compiles correctly, but when QGIS starts, I get a Python error:

   File "/home/goocreations/apps/share/qgis/python/qgis/utils.py", line 283,
in _import
     mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: /home/goocreations/apps/lib/libqgis_mylib.so.1.7.0: undefined
symbol: _ZN15MyClassIiEC1E7QString
> From the error I would expect that the body of the MyClass(QString s)
constructor is missing: you have only declared it.


So, I've though that creating a SIP binding for MyClass may resolve the
issue, but I can't figure out how I would use templates in SIP.
SIP refers to template classes as "mapped types". Here you can find
some documentation:
http://www.riverbankcomputing.co.uk/static/Docs/sip4/directives.html#directive-%MappedType

Regards
Martin


_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to