23 May 2013 15:47
Fwd: Re: std::vector of class with no default constructor
Christopher Botos <cbotos <at> aer.com>
2013-05-23 13:47:32 GMT
2013-05-23 13:47:32 GMT
Thanks so much, Vadim. There were three such compile
errors and this fixed two of them.
Adding the following fixed the third:
%ignore std::vector<CppClassName>::pop;
With this, it compiled and worked!
Thanks, again.
-Chris
------------------------------------------------------------------------------
From: Vadim Zeitlin <vz-swig <at> ze...> - 2013-05-22 16:14
Hello,
I use the following before the %template directive for the classes without default ctor:
%ignore std::vector<CppClassName>::vector(size_type);
%ignore std::vector<CppClassName>::resize;
HTH,
VZ
-------- Original Message --------
Hi,
I have a struct that contains a member that is a vector of a class with no default constructor that is not compiling. I condensed the problem into the short example below that gives a few of the following compile errors:
error: no matching function for call to Instrument::Instrument()
I tried applying what is said about this in Section 6.6.1 "Constructors and destructors" but without success.
Can someone suggest how I might get around this?
Here's the example code:
//---------------------------------------------------------
%module Band
%feature("autodoc", "1");
//%feature("valuewrapper") Instrument;
//%clearnodefaultctor;
//%nodefaultctor Instrument;
//%feature("notabstract") Instrument;
%{
#define SWIG_FILE_WITH_INIT
#include <vector>
class Instrument
{
public:
Instrument(int aNote) : theNote(aNote) {}
int play() {return theNote;}
private:
int theNote;
};
struct Section
{
std::vector<Instrument> theInstruments;
};
%}
%include "std_vector.i"
typedef std::list<PG::L2::LS::DateTime> DateTimeVector;
typedef std::vector<Instrument> InstrumentVector;
%template(InstrumentVector) std::vector<Instrument>;
//---------------------------------------------------------
Thanks in advance.
Regards,
Chris
Adding the following fixed the third:
%ignore std::vector<CppClassName>::pop;
With this, it compiled and worked!
Thanks, again.
-Chris
------------------------------------------------------------------------------
From: Vadim Zeitlin <vz-swig <at> ze...> - 2013-05-22 16:14
Hello,
I use the following before the %template directive for the classes without default ctor:
%ignore std::vector<CppClassName>::vector(size_type);
%ignore std::vector<CppClassName>::resize;
HTH,
VZ
-------- Original Message --------
| std::vector of class with no default constructor |
| Wed, 22 May 2013 11:30:40 -0400 |
| Botos, Christopher <cbotos <at> aer.com> |
| swig-user <at> lists.sourceforge.net. |
Hi,
I have a struct that contains a member that is a vector of a class with no default constructor that is not compiling. I condensed the problem into the short example below that gives a few of the following compile errors:
error: no matching function for call to Instrument::Instrument()
I tried applying what is said about this in Section 6.6.1 "Constructors and destructors" but without success.
Can someone suggest how I might get around this?
Here's the example code:
//---------------------------------------------------------
%module Band
%feature("autodoc", "1");
//%feature("valuewrapper") Instrument;
//%clearnodefaultctor;
//%nodefaultctor Instrument;
//%feature("notabstract") Instrument;
%{
#define SWIG_FILE_WITH_INIT
#include <vector>
class Instrument
{
public:
Instrument(int aNote) : theNote(aNote) {}
int play() {return theNote;}
private:
int theNote;
};
struct Section
{
std::vector<Instrument> theInstruments;
};
%}
%include "std_vector.i"
typedef std::list<PG::L2::LS::DateTime> DateTimeVector;
typedef std::vector<Instrument> InstrumentVector;
%template(InstrumentVector) std::vector<Instrument>;
//---------------------------------------------------------
Thanks in advance.
Regards,
Chris
------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________ Swig-user mailing list Swig-user <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/swig-user
RSS Feed