non const reference
Remy Muller <[email protected]> Wed, 08 Feb 2012 12:12:04 +0100
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
hi,
here's a toy example I'd like to wrap using luabind:
struct A
{
private
A(const A&) {}
};
struct B
{
virtual void foo(A &a)
{
}
};
struct B_wrap : public B, public wrap_base
{
virtual void foo(A &a)
{
call<void>("foo", a);
}
static void default_foo(B *p, A &a)
{
p->B::foo(a);
}
};
module(L)[
class<A>,
class_<B, B_wrap>("B"),
.def("foo", &B::foo, &B_wrap::default_foo)
];
I have questions regarding this:
the compiler complains because A constructor is private
1) Is there a non-intrusive way to inform luabind that a pointer to A*
could be used instead of the reference to avoid the copy?
2) I guess a static forwarding function like:
static function void static_foo(B *b, A *a)
{
assert(b && a);
b->foo(*a);
}
would solve my first question, but how to make that play well with
virtual function overloading?
3) how can I tell luabind that the lifetime of this object is only
guaranteed during this function call and shouldn't be acquired by lua code?
best
remy
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d