Taking a function or delegate as argument.
doob at me.com
Tue Jan 10 23:19:48 PST 2012
On 2012-01-11 02:05, Stewart Gordon wrote:
> On 10/01/2012 19:56, Jacob Carlborg wrote:
>> A template parameter with a template constraint will accept any
>> callable type. Function
>> pointer, delegate, struct/class overloading the call operator and so on.
> Indeed, this is done in the C++ STL quite a lot.
> The drawback is that templated methods lose their virtuality, because it
> cannot be known in advance on what types the template will be
> instantiated in order to populate the vtable.
> FWIW my utility library includes a delegate wrapper:
> (dgwrap works in both D1 and D2, though other bits of the library need
> updating to current D2)
Yeah, it all depends on what the needs are.
More information about the Digitalmars-d-learn