Re: Boost.function enhanced (a little)
* Mathias Gaunard:
On 15 oct, 15:08, "Alf P. Steinbach" <al...@start.no> wrote:
Except this isn't type erasure as defined in C++ literature.
By definition, type erasure requires dynamic memory allocation because
it needs to be able to contain objects of *arbitrary* types,
And the code I presented does that.
You're only allowing bound member function pointers, not arbitrary
types that are callable.
That's quite misleading. I presented an example of binding member function
pointers since that was what we discussed. I would only have exemplified
something else if the something else (what? I'm not telepathic, I don't know
what you think would have been nice if exemplified) had been relevant.
The only thing you're erasing is the type of the class object.
When I show someone who has denied the posssible existence of radios, how to
very simply build a radio, the comment "the only thing you've created is a
radio" is perhaps not so much perplexing as expected, but it's sad anyway.
which
means of *arbitrary sizes*, that satisfy a given *structural
interface*, also known as a *concept*.
No, I'm sorry but that's not even wrong: you're talking about a
generalization
and the requirements of fully supporting that (irrelevant) generalization,
like
a car needs to have wings and a rocket engine in order to be a fully
general
transportation vehicle -- think about it, it's idiocy.
I think I understand your point now. You think the function object
abstraction is too general and would rather settle with only function
and bound member function pointers.
I'm sorry, no, you don't understand: you've dropped the context. All this
concrete exemplifying etc. was in response to a statement you made that it was
impossible. It's called a "counter example".
The context of this discussion is delegate support.
What a delegate is within the scope of C++ is slightly different from
other languages, in particular due to lack of garbage collection. The
closure may need to hold part of its context by value, which means the
function object can be arbitrarily large.
I'm sorry, no, there's no hard definition of "delegate" in the context of C++.
But there is a common meaning, from languages such as C#. And it is a term that
*I* have used in this discussion, with that common meaning. There's absolutely
no way that a less practical meaning can be retrofitted to the articles already
posted. So, just forget that approach: it's for politicians only. :-)
Cheers & hth.,
- Alf
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]