Overloads w/shared_ptr

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Overloads w/shared_ptr

Stefan Schindler
Hi guys,

I'm currently having a problem with specifying a custom overload for the
following definition:

typedef boost::shared_ptr<Foobar> FoobarPtr;

void wrapped_do_something( FoobarPtr object ) {
        ...
}

class_<Foobar, FoobarPtr>( "Foobar" )
        .def( "do_something", &wrapped_do_something )
;

Compiles fine, however when calling 'do_something' from Lua, it
complains about not finding a matching overload. The first parameter is
named "custom [N5boost10shared_ptrIN6FoobarEEE]" in the error message.

My assumption is that at the time 'wrapped_do_something' is defined with
'.def', it's not known that 'Foobar' objects are being held by
'FoobarPtr'. However I don't have an idea how to solve it.

Greetings,
Stefan.


------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Overloads w/shared_ptr

eduard mueller
A wild quick guess: Try passing a [const] reference instead.
void wrapped_do_something(const FoobarPtr& object) or
void wrapped_do_something(FoobarPtr& object)

Also remember the ugly colon in Lua (I personally just can't get used to it):
obj:do_something() or obj.do_something(obj)


On Wed, Aug 17, 2011 at 10:20, Stefan Schindler <[hidden email]> wrote:

> Hi guys,
>
> I'm currently having a problem with specifying a custom overload for the
> following definition:
>
> typedef boost::shared_ptr<Foobar> FoobarPtr;
>
> void wrapped_do_something( FoobarPtr object ) {
>        ...
> }
>
> class_<Foobar, FoobarPtr>( "Foobar" )
>        .def( "do_something", &wrapped_do_something )
> ;
>
> Compiles fine, however when calling 'do_something' from Lua, it
> complains about not finding a matching overload. The first parameter is
> named "custom [N5boost10shared_ptrIN6FoobarEEE]" in the error message.
>
> My assumption is that at the time 'wrapped_do_something' is defined with
> '.def', it's not known that 'Foobar' objects are being held by
> 'FoobarPtr'. However I don't have an idea how to solve it.
>
> Greetings,
> Stefan.
>
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Overloads w/shared_ptr

Peter Colberg-3
In reply to this post by Stefan Schindler
On Wed, Aug 17, 2011 at 10:20:00AM +0200, Stefan Schindler wrote:

> I'm currently having a problem with specifying a custom overload for the
> following definition:
>
> typedef boost::shared_ptr<Foobar> FoobarPtr;
>
> void wrapped_do_something( FoobarPtr object ) {
> ...
> }
>
> class_<Foobar, FoobarPtr>( "Foobar" )
> .def( "do_something", &wrapped_do_something )
> ;
>
> Compiles fine, however when calling 'do_something' from Lua, it
> complains about not finding a matching overload. The first parameter is
> named "custom [N5boost10shared_ptrIN6FoobarEEE]" in the error message.

Did you #include <luabind/shared_ptr_converter.hpp>?

Peter

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user