JakobOvrum/LuaCpp

Broken example?

Opened this issue · 2 comments

If I'm not mistaken the sample http://jakobovrum.github.com/LuaCpp/config_8cpp-example.html is technically broken.

const char* bar;
c.bar = t["bar"];

This will invoke the char * conversion which does not imply a copy, and since there's no copy the data is liable to be removed depending on what happens in the Lua state.

Noted without testing or even looking at the latest version of your code so bleah.

This is one of the reasons I stopped working on this. I can't remember the details, but something about std::string having both a copy constructor and a non-explicit constructor const char* caused a shitload of problems when converting the index expression to strings.

My initial plan was for conversion to a C string to work just like the C API, you'd use the pointer under the terms of lua_tolstring. Conversion to std::string would be the safe version. std::string's implicit constructor for const char* caused problems so I tried with support for std::string only, but I still got errors...

I can't really remember the details but I was frustrated over a couple of other things too, so the project is in a state where this isn't sorted out.

I think it's a valid time to point out #5