memoize

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jan 4 06:11:01 PST 2011


On 1/4/11 7:54 AM, Simen kjaeraas wrote:
> Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 1/4/11 12:30 AM, Guilherme Vieira wrote:
>>> Is there really need for ParameterTypeTuple? I figured this works:
>>>
>>> template memoize(alias fun, uint maxSize = uint.max)
>>>
>>> {
>>>
>>> auto memoize(Args...)(Args args)
>> [snip]
>>
>> That would create several caches, depending on calls with convertible
>> arguments.
>>
>> Andrei
>
> So the solution should use a struct with overloaded opCall, then.

1. I think it's best to map a function to a function for best impedance 
match.

2. If you memoize an overloaded function, you _do_ want several caches.


Andrei


More information about the Digitalmars-d mailing list