Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2003-10-09 11:25:06


David Abrahams <dave_at_[hidden]> wrote:
> "Joel de Guzman" <joel_at_[hidden]> writes:
>
>> David B. Held <dheld_at_[hidden]> wrote:
>
>> struct square
>> {
>> template <class X>
>> struct sig { typedef X type; }
>> template <class X>
>> X operator()(X x) { return x * x; }
>> };
>>
>>>> [...]
>>>> b. It should be called apply, because that just makes it
>>>> cheaper and easier to use: instead of
>>>> [...]
>>>
>>> But my understanding is that apply<> is the compile-time way
>>> to spell "operator()" for function objects.
>
> Sort of.
>
>>> If sig<> is really the definition of R for "R operator()", without
>>> being the result of operator(), should it really be spelled
>>> "apply<>"? It seems to me that there is a confusion between
>>> runtime and compile time here. The fact that apply<> works
>>> syntactically adds to the confusion.
>
> *I'm* not confused. I have no problem with the idea of having a
> class
>
> a. whose _instances_ can be used as a function which squares numbers
>
> b. which is itself a metafunction class that computes the instance's
> return type based on the arguments passed

Snips...

For the record, I am not against naming it "apply". However, I am not sure
how that will jive with Doug's uniform return type proposal. I'm sure
we do agree that there must be one and only one way to do it.

Cheers,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk