Re: Derived Lua objects in C++ containers (with smart pointers)
Glen Fraser <[email protected]> Mon, 8 Jul 2013 15:04:45 +0200
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
On Jul 8, 2013, at 2:04 PM, "Christian" <[email protected]> wrote: >> The complicating factor (maybe) is that I'd like to use smart pointers in the containing >> STL vector, and I don't see how to use both luabind::wrap_base and a smart pointer at the >> same time, in the class_ binding. > > I think you identified the problem correctly. Have you read > http://www.rasterbar.com/products/luabind/docs.html#smart-pointers ? > You need to specify ofPtr as an template argument when registering your class and make sure > that a get_pointer() function is available in the same namespace as ofPtr (global is only > sufficient if ofPtr is itself global). Yes, I had indeed read it -- but where I went wrong was assuming ofPtr supported get_pointer(). It doesn't. It's not based on boost::shared_ptr but rather std::shared_ptr, which doesn't include a get_pointer() method. Changing my code to use boost::shared_ptr, it all works fine. Otherwise, I could add a get_pointer() function, as in your code. Thanks! Glen. > >> (in the below code, assume [...] ofPtr is just shared_ptr) > > boost::shared_ptr? Then just specify ofPtr as template argument, as said above, and you > should be done. > If not, you additionally need to supply an appropriate get_pointer() function. For > std::shared_ptr, you can use a header I made for this purpose (just include it): > http://github.com/Oberon00/luabind/blob/master/luabind/std_shared_ptr_converter.hpp > > I hope I could help, > Christian ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev