Re: Discarding shared_ptrs
Simon Pickles <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
On 07/06/2011 01:11, Jason McKesson wrote:
> There's no reason you can't use a weak_ptr in Lua. The weak_ptr is a C++
> object, just like any other. You can bind that object with Luabind and
> so forth.
Well I tried using shared_ptrs and at the end of the function, setting
them to nil in Lua but it doesnt decrement the use_count:
-- Lua
-- entity is a boost::shared_ptr<Entity> in c++
-- entity.use_count() in c++ = 3
mission["enter"] = function( entity )
{
entity:DoSomething()
entity = nil
}
-- entity.use_count() in c++ = 4
It appears the 'entity = nil' line has no effect.
I'll try weak pointers
S
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev