Const reference

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Const reference

Alexander Gladysh
Hi, all!

(Quick minimal sample, have not compiled it)

  struct foo; // registered to Luabind

  struct bar
  {
    void baz(const foo & val);
  };

  luabind::class_<bar>("bar_t")
    .def(luabind::constructor<>())
    .def("baz", &bar::baz)
    ;

  -- Lua:

  local foo = something_to_get_foo()
  local bar = bar_t()
  bar:baz(foo)

The last line generates error like this:

  no overload of  bar_t:baz matched the arguments (const foo)
  candidates are:
  bar_t:baz(const foo&)

Can I make this code work without changing bar definition (like adding
bar::baz(const foo))? In this specific case with foo and bar I want
Luabind to behave identically on both by-reference and by-value
versions of bar::baz().

The side question: if there is no way to use bar_t:baz(const foo&)
from Lua, I guess the registration code should be nice and tell me
this (with either compile-time or binding-time error)...

Thanks in advance,
Alexander.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Const reference

Alexander Gladysh
> Can I make this code work without changing bar definition (like adding
> bar::baz(const foo))? In this specific case with foo and bar I want
> Luabind to behave identically on both by-reference and by-value
> versions of bar::baz().

Sorry, please disregard my previous post -- I've just accidentally
called method with '.' instead of ':'... :(

Alexander.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user