David Abrahams wrote:
Hossein Haeri wrote:
Dave,
...
can't do that for a functor. Is that right?
That's because function object types (what you're calling functors)
It's not me, AFAIK. That's another common name of them. Isn't that?
Yes, but it's frowned upon by many because it's a completely invented meaning for a term that already had a well-established meaning in mathematics and computing. If you read Stroustrup or almost any other author who's also on the committee you'll see the term "function object" and not "functor."
I had copied this description from a letter from the editor in either CUJ or C++ Report some years back. ---------- Here's the low-down, to which any mathematician would attest: A function is a transformation that maps an element to an element. A functional is a transformation that maps a function to an element. A functor is a transformation that maps a function to a function. (The truth functions in propositional logic are also sometimes called functors.) Simple, isn't it? We seem to use the first one correctly, but not the other two. What people commonly call a functor (thanks to Dr. Coplien, shame!) is what the C++ Standard calls a function object. It seems some people like to use "functional" to mean the same thing. Shame again! A function object is simply that, an instance of a class that behaves like a function by virtue of its operator(). Some function objects, like bind2nd, do behave like functors, in that they take a function object as input and return a function object as output. Only these deserve the functor moniker, although you may prefer "function object adaptor" (or is it spelled "adapter" :-), as denoted in the C++ Standard. ---------- Jeff