|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-11-23 11:55:27
From: "Kevlin Henney" <kevlin_at_[hidden]>
> >The counted callback more closely mirrors a function pointer, in the case
> >where the function has state (static variables.)
>
> Not sure I agree that it does quite make this case. I think built-in
> semantics are surprisingly neutral on the topic.
Actually the built-in semantics aren't exactly duplicated by the counted
callback, also:
int f()
{
static int i = 0;
return ++i;
}
int (*g)() = f;
int (*h)() = g;
f(); // 1
g(); // 2
h(); // 3
-- class F { public: F(int j): i(j) {} int operator()() { return ++i; } private: int i; }; { F f; counted_callback<int> g(f); counted_callback<int> h(g); f(); // 1 g(); // 1 h(); // 2 } { F f; cloning_callback<int> g(f); cloning_callback<int> h(g); f(); // 1 g(); // 1 h(); // 1 } -- 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