[C++-sig] Re: beginner : call_policies

David Abrahams dave at boost-consulting.com
Mon Feb 16 15:23:15 CET 2004

"Benjamin Golinvaux" <Benjamin.Golinvaux at euresys.com> writes:

> Dear list members,
> I would like to know if it's possible to write my own 
> call policies, in order to be able to handle the reference
> counting of objets dynamically, based on some return values
> of my wrapped C++ functions. For example
> struct A {};
> struct B 
> {
> 	bool foo(A& someA);
> 	A _a;
> }
> where i would like B::foo(someA) to increment someA reference count
> if it returns "true", and don't do anything otherwise.
> (so basically i would like to tie someA's lifetime to the instance
> of B ONLY IF the function returns "true".
> is this possible with some precall/postcall magic ?

Yes, it certainly is possible.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list