Pass argument by reference.

"Valery" <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <3b8201c9dabe$02762b70$80aea8c0@winxpvpc>
Hello,

I am new in luabind. I am trying to pass argument by a reference to std::string.
When I use const reference to std::string. It works.
The following code works:
--------------------------------
.lua
function test(a)
 c_ref(a)
end

.cpp
void c_ref(const std::string& val) 
{ 
    std::cout << val;
}
module(L)
[
    def("c_ref", &c_ref)
];
luabind::call_function< void >(a_state, "test", str);
--------------------------------

But as soon as I change 'const std::string&' to 'std::string&' and 'str' to 'boost::ref(str)', it does not work. I got "you are trying to use an unregistered type".
--------------------------------
void c_ref(std::string& val) {}
luabind::call_function< void >(a_state, "test", boost::ref(str));
--------------------------------

It is not clear for me why std::string is known class, but std::string& does not.

Could you please explain? And how to fix my second sample?

Thanks,
Valery.

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.