Squirrel
The programming language
Welcome to Squirrel
Sign in
|
Join
|
Help
in
Embedding (forum)
General (group)
(Entire Site)
Search
Home
Forums
Squirrel
»
General
»
Embedding
»
[SQPlus] binding templated class
[SQPlus] binding templated class
Last post 06-22-2009, 2:41 PM by
DoMeN
. 4 replies.
Sort Posts:
Oldest to newest
Newest to oldest
Previous
Next
06-20-2009, 2:30 PM
3319
DoMeN
Joined on 04-11-2008
Posts 7
[SQPlus] binding templated class
Reply
Quote
Hy, is there a way to bind a ( specialized ) templated class with SQPlus?
for e.g. such a class:
template< typename T >
class foo
{
};
bind_with_sqplus( foo< unsigned int > );
If it's not possible with sqplus, is it possible with any other binder?
regards,
Domen
Report abuse
06-21-2009, 1:32 AM
3320
in reply to
3319
DoMeN
Joined on 04-11-2008
Posts 7
Re: [SQPlus] binding templated class
Reply
Quote
I want to use DECLARE_INSTANCE_TYPE( foo< unsigned int > ); so that I could use it as a variable in squirrel.
Report abuse
06-21-2009, 1:03 PM
3321
in reply to
3320
juggernaut
Joined on 11-27-2006
Posts 66
Re: [SQPlus] binding templated class
Reply
Quote
See testSqPlus2.cpp for an example...
You need to do something like this:
template<typename T>
struct Point {
Point() {}
Point(T X, T Y) : X(X), Y(Y) {}
T X, Y;
};
typedef Point<float> Pointf;
DECLARE_INSTANCE_TYPE(Pointf)
Report abuse
06-22-2009, 2:16 PM
3323
in reply to
3321
DoMeN
Joined on 04-11-2008
Posts 7
Re: [SQPlus] binding templated class
Reply
Quote
Thx for the hint. I tested the sample and there were no problems with compiling them.
But in my case I still get this error:
EXTERNAL/SQUIRREL2_1_1_sqplus_snapshot_20080713/SHARED/include_sqplus/sqplus.h|689|error: no match for ‘operator=’ in ‘* newClass = classToCopy’|
note: candidates are: LD_Array<T>& LD_Array<T>::operator=(LD_Array<T>&) [with T = unsigned int]|
I guess that it has a problem with my overloaded operator=
How should I write operator= to use the class with SQPlus?
Report abuse
06-22-2009, 2:41 PM
3324
in reply to
3323
DoMeN
Joined on 04-11-2008
Posts 7
Re: [SQPlus] binding templated class
Reply
Quote
OK I've finally managed to compile it... the only thing that had to be changed was to put const in front of LD_Array<T>&...
Thx for the help
Report abuse
Alberto Demichelis 2003-2008