   Tolua++: Multiple template parameters
  I was very happy with tolua++, till I tried to bind a class with multiple template parameters, 2 in fact.This is what the  official  documentation has to say about it:Quote:Similarily, a template with more than 1 macro could be bound, and it could also inherit from another template:class hash_map : public map<K,V> {TOLUA_TEMPLATE_BIND(K V, int string, string vector<double>)V get_element(K key);void set_element(K key, V value);hash_map();~hash_map();};And here is my pkg file:class CMessengerServer: public CServer<CClient,CBuffer>{TOLUA_TEMPLATE_BIND(CClient CBuffer, CClientBase CBufferBase)public:    typedef stdext::hash_map<unsigned long long,CClient*> CClientHash;    CMessengerServer();    ~CMessengerServer();    inline void SetName(std::string name)    {   this->name=name;    }    inline std::string GetName()    {   return name;    }...There is no "," between the templates arguments, and so I did in my pkg file.The thing is, without the "," the pkg file will not "Compile" (tolua binder), and with "," it generates wrong code, like: CServer<CBuffer>* self = (CServer<CBuffer>*) tolua_tousertype(tolua_S,1,0); (it is trying to specialize the template with the template wild card type)I've tried a bunch of things, like:TOLUA_TEMPLATE_BIND("CClient CBuffer","CClientBase CBufferBase")TOLUA_TEMPLATE_BIND((CClient CBuffer,CClientBase CBufferBase))All of then failed to produce a decent code for one reason or another.Someone knows the right way to do it?EDIT: My Pkg file is different from the one I've posted here. The one I used contains this TOLUA_TEMPLATE_BIND(CClient CBuffer,CClientBase,CBufferBase), with a coma between the types CClientBse and CBufferBase. But it stil doesn't work.The complete error log:Quote:C:\Program Files (x86)\CodeBlocks\Projects\server>tolua -o binder.cpp binder.pkg ***curr code for error is class CServer{TOLUA_TEMPLATE_BIND(CClient CBuffer,CClientBase,BufferBase)public:    CServer();    virtual ~CServer();    bool Start(int port,unsigned n_buffers=100,int buffer_size=1024, int nt=2,int queued_accepets=5);    void Finish();    bool PostSend(CClient* client,const _cstring  buf, int size);    unsigned GetNumberOfProcessors()    {   return n_processors;    }    std::string GetIp()    {   return ip;    }};stack traceback:[string "tolua embedded: src/bin/lua/basic.lua"]:91: in function 'tolua_error'[string "tolua: embedded Lua code 22"]:5: in main chunk** tolua internal error: [string "tolua embedded: src/bin/lua/class.lua"]:170: attempt to concatenate field '?' (a nil value).stack traceback:[string "tolua: embedded Lua code 22"]:6: in main chunk[Edited by - Escarab on February 22, 2009 9:23:36 AM]
  Come on guys, this is really driving me crazy, not even a clue? I really need some help with this, please   ;  Are you binding a class which is templated? It doesn't seem like it. It looks like the C++ definition of the class is as such . You class..class CMessengerServer: public CServer<CClient,CBuffer>{.... code here};This class doesn't accept any templated parameters at all. The marco your using is used for classes with this definition.template <class K, class V> class CMessengerServer: public CServer<K,V>{.... code here};Where the template parameters K,V are defined at compile time by the linesCMessengerServer<float,int> TestServer;for instance, then u would use the marco as follows :template <class K,class V> class CMessengerServer: public CServer<K,V>{TOLUA_TEMPLATE_BIND(K V, float int).... code here};To tell toLua that there exist an instance of the class CMessengerServer which has the template parameters K & V to be defined as float & int respectively.Your class is just a standard class  and should use normal toLua binding for a standard class.Good Luck!-ddn   ;  There is a solution that works in C++03 (though I am not sure if this 100% what you need):#include <iostream>void fun (int) { std::cout << "called with one argument\n"; }void fun (int, int) { std::cout << "called with two arguments\n"; }void fun (int, int, int) { std::cout << "called with three arguments\n"; }#define pack2(arg1, arg2)  arg1,arg2#define cpp_fun(x)  fun(x)int main () {    cpp_fun(pack2(1,1));    cpp_fun(pack2(1,pack2(2,3)));}output:called with two argumentscalled with three argumentsVariadic macros could help you, but you have to rely on special compiler flags to enable C99 or C++0x support.   ;  ddn3: Yes, my class is a class template. But in the pkg file, you must not define it as a template, as you can see in the example provided by the official documentation. You must use the TOLUA_TEMPLATE_BIND to define a template in the pkg file, as I`m doing.The problem is; this macro is not working as it should. The example given by the documentation is very close to my problem, but it simply does not work.with just one template parameter, the macro works fine.I'm thinking in chnge to swig or luabind, or redefine the macro myself. What do you think?thanks for the input   ;  Try simplifying your template parameters name to a single variable like K,V. It could be the parser for the template in toLua can't handle complex named types like your using.If this is an isolated case, write your own bindings for this object or worse case use Mluabind or Luabind in conjunction with toLua, they can coexist i believe.Good Luck!-ddn;  I've decide to change completely to luabind.thank you all.   