|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-11-22 11:28:32
I have updated function_ptr in the vault. This version supports void returns
under MSVC6.4, g++ 2.95.2, bcc32 5.51.
function_ptr uses cloning on copy instead of reference counting. I'm not
sure which behavior is "better." A cloning function_ptr is thread-safe and
has the property that the copies are independent:
class Rand // a pseudo random number generator
{
public:
explicit Rand(int);
int operator()();
private:
// ...
};
function_ptr0<int> fp = Rand(42); // seed
function_ptr0<int> fp2(fp);
assert(fp() == fp2());
A reference counted function_ptr has less copy overhead, but the copies
affect each other.
I'm still undecided on the other issue... whether function_ptr2<void, int,
int> is better/worse than function_ptr<void, int, int>.
function_ptr doesn't attempt to handle member pointers; I think that a
portable LL bind (expression.hpp apply) subset will be a better solution for
this problem.
(bcc551_bug.cpp in the same folder demonstrates what I believe to be a bug
in bcc 5.51 - it doesn't strip cv qualifiers from arguments when deducing
template parameters. Any C++Builder users care to submit this to Borland?)
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk