Pass argument by reference.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Pass argument by reference.

Valery-8
 
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user