Re: return_stl_iterator acting as const?
John Smith <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
I hate replying to myself but I also noticed that this problem is only in the case where the vector is storing an object not a pointer to an object. (Which is why I think I'm hitting a copy constructor at some point instead of having it pass by reference) If I was to modify the container to be std::vector<ContainedObject *> vec;, and modify the test code to be: ContainerObject cont; ContainedObject* Obj = new ContainedObject; Obj->value = 10; cont.push_back(Obj); Then when I come out of the call_function Obj has the expected value of 5. Anyone have other ideas/thoughts? On Tue, Mar 3, 2009 at 1:57 AM, John Smith <[email protected]> wrote: > I don't believe so, changing that to be : gave the following errors: > print(cont:containervalue) > function arguments expected near ')' for that line > > for things in cont:vec > gave the error: > function arguments expected near 'do' > > My understanding of the : notation was that it was a shorthand of: > x:y is equivilant to x.y(x) > > Therefore, trying: > for things in cont:vec() > > gave a luabind exception of 'No such operator defined' > > > > On Tue, Mar 3, 2009 at 1:26 AM, James Porter <[email protected]> wrote: > >> John Smith wrote: >> > Lua code: >> > function LuaFunction( cont ) >> > print (cont.containervalue) >> > cont.containervalue = 30 >> > for things in cont.vec >> > do >> > print (things.value) >> > things.vlaue = 5 >> > end >> > end >> >> It looks like you're using the wrong syntax for getting at your members. >> In Lua, "." is similar to "::" in C++, while ":" in Lua is similar to >> "." in C++. You want cont:containervalue, cont:vec, and so on. The >> former is working because you're defining a new static variable, >> essentially. >> >> - Jim >> >> >> ------------------------------------------------------------------------------ >> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, >> CA >> -OSBC tackles the biggest issue in open source: Open Sourcing the >> Enterprise >> -Strategies to boost innovation and cut costs with open source >> participation >> -Receive a $600 discount off the registration fee with the source code: >> SFAD >> http://p.sf.net/sfu/XcvMzF8H >> _______________________________________________ >> luabind-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/luabind-user >> > > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user