On Wed, Jul 30, 2014 at 1:29 PM, Peter Dimov
Klaim - Joël Lamotte wrote:
I might have misunderstood what Peter suggested: I thought he suggested
that get_symbol<> would return a smart pointer (not shared_ptr) that would _internally_ contain a shared_ptr to the plugin and the access to the data.
No, get_symbol returns a 'real' shared_ptr in my suggestion.
shared_ptr<library> p = load_library( "mylib.so" ); shared_ptr
p2 = get_symbol ( p, "myfunction" ); (*p2)(); // calls myfunction() in mylib.so By creating p2 using the aliasing constructor of shared_ptr, you can have p2 and p share ownership of the loaded library.
template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept; Effects: Constructs a shared_ptr instance that stores p and shares ownership with r. Postconditions: get() == p && use_count() == r.use_count() [ Note: To avoid the possibility of a dangling pointer, the user of this constructor must ensure that p remains valid at least until the ownership group of r is destroyed. —end note ]
Ok, thanks now I see what you actually meant, sorry for the noise.
Could you clarify what would happen here:
shared_ptr
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/ mailman/listinfo.cgi/boost