|
Boost Users : |
Subject: Re: [Boost-users] Delegating to boost::function with arbitrary signature
From: Bjorn Reese (breese_at_[hidden])
Date: 2013-12-14 10:25:45
On 12/14/2013 03:49 PM, Alexander Lamaison wrote:
> I'm trying to create something like a `boost::function`, but with an
> extra 'smart handle' tucked inside, which controls the lifetime of a
> resource the functions needs to execute correctly.
The two aspects (resource life-time and generic signatures) should
probably be handled separately.
Regarding resource life-time, a common pattern is to bind to a member
function on an object obtained via shared_from_this(). Here is an
example from Boost.Asio:
http://www.boost.org/doc/html/boost_asio/tutorial/tutdaytime3.html
Regarding generic signatures I am less certain, but maybe you could look
into Boost.TypeErasure. Especially its type-safe printf example (or the
subsequent example with multiple signatures)
http://www.boost.org/doc/html/boost_typeerasure/examples.html#boost_typeerasure.examples.printf
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net