Boost logo

Boost Users :

Subject: [Boost-users] [interceptors] How to intercept when a function is called
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2014-07-02 15:32:01


Hello,

I don't know if there is a first or second class library in Boost to
do with this already. Or at least a C++ mechanism I could leverage.

Basically, I want to hook or intercept when a function call is made. I
do not want to change the underlying call, although I suppose that
hook could be done as well. For now, I just want a callback when that
function calls is made.

For instance, a vector push_back listener. I want to listen when items
are push_back-ed onto the vector. The items should still land in the
vector. I just want the notification when that occurs.

I've dug around for different "callback" flavors, but these just seem
to be wrappers to an underlying method pointer, bound function, along
these lines. I can do that easy enough but it doesn't buy me the
interception when the push back is actually called.

The tricky part with push_back as well, is that it comes in two
flavors, so there needs to be a stand in lambda, something to declare
the actual kind of argument(s) I want. Then there's the matter of
Variadics. But for now I am not concerned with either of these.

Thank you...

Best regards,

Michael Powell


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