Problem with == operator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with == operator

chrislu
hi,
i have a problem with the == operator. in the following example the  
operator is never called:

class optest
{
public:
     optest() {}

     bool operator==(float rhs) const {
         return (_f_data == rhs);
     }

     bool operator==(int rhs) const {
         return (_i_data == rhs);
     }

     bool operator==(const std::string& rhs) const {
         return (_s_data == rhs);
     }

     float       _f_data;
     int         _i_data;
     std::string _s_data;
};

void register_lua_bindings(lua_State* l_state)
{
     op_test._f_data = 1.1f;
     op_test._i_data = 2;
     op_test._s_data = "ssw";

     using namespace luabind;

     module(l_state)
     [
         class_<optest>("optest")
             .def(constructor<>())
             .def(const_self == int())
             .def(const_self == float())
             .def(const_self == other<std::string>())
     ];

     globals(l_state)["op_test"] = op_test;
}

lua code:
> print(op_test == 2)
false
> print(op_test == 1.1)
false
> print(op_test == "ssw")
false

What am i doing wrong... ?

i also tried adding:
     bool operator==(float rhs) const {
         return (_f_data == rhs);
     }
and
     .def(const_self == other<optest>())

but without no effect.

-chris

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user