Taking a function or delegate as argument.

Jacob Carlborg 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:
> <snip>
>> 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:
> http://pr.stewartsplace.org.uk/d/sutil/
> (dgwrap works in both D1 and D2, though other bits of the library need
> updating to current D2)
> Stewart.

Yeah, it all depends on what the needs are.

/Jacob Carlborg

More information about the Digitalmars-d-learn mailing list