tostring operator doesn't compile if argument is non const
Lorenzo Pistone <[email protected]> Wed, 10 Apr 2013 01:57:00 +0200
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Hello,
the example in the docs to bind the tostring operator
(http://www.rasterbar.com/products/luabind/docs.html#operators) doesn't
compile. I write it here for reference:
#include <luabind/luabind.hpp>
#include <luabind/operator.hpp>
#include <ostream>
class number {};
std::ostream& operator<<(std::ostream& o, number&){ return o; }
int main(){
lua_State* L = NULL;
using namespace luabind;
module(L)[class_<number>("number").def(tostring(self))];
}
It compiles only if you put use this signature for <<:
std::ostream& operator<<(std::ostream& out, const A&)
Also, I would expect that const_self is required in the def, but it
seems that it doesn't matter. Is this intended behaviour or a bug?
Cheers.
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter