Re: tostring() operator outside class?
Kristoffer Danielsson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Ah, thanks a lot! :) > Date: Wed, 19 Jan 2011 09:57:51 +1100 > From: [email protected] > To: [email protected] > Subject: Re: [luabind] tostring() operator outside class? > > I sometimes do this. > > .... > .def( "__tostring", &testToString ) > .... > > std::string testToString( const Test* t ) > { > return std::string( 'An instance of test.' ); > } > > Returning a "const char*" instead works too I think, but I'm not 100% on > that. > > HTH > > Nigel > > On Tue, January 18, 2011 10:49 pm, Kristoffer Danielsson wrote: > > > > > > Consider this: > > > > ,luabind::class_<Test>("Test") > > .def(luabind::tostring(luabind::const_self)) > > > > ostream& operator << (ostream &os, const Test &test) > > { > > os << test.value; > > return os; > > } > > > > Is it possible to NOT have this friend operator of class Test and map it > > in another way? Something like this: > > > > ,luabind::class_<Test>("Test") > > .def(luabind::tostring(test_tostring_operator)) > > > > void test_tostring_operator() { blah } > > > > > > Thanks > > ------------------------------------------------------------------------------ > > Protect Your Site and Customers from Malware Attacks > > Learn about various malware tactics and how to avoid them. Understand > > malware threats, the impact they can have on your business, and how you > > can protect your company and customers by using code signing. > > http://p.sf.net/sfu/oracle-sfdevnl_______________________________________________ > > luabind-user mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/luabind-user > > > > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user