higher-order funcs for ranges (with usual interface)
spir
denis.spir at gmail.com
Mon Feb 7 11:01:02 PST 2011
On 02/07/2011 01:07 PM, Torarin wrote:
> If you want to use an interface as a concept, you can take kenji's
> adaptTo module and add this:
>
> template conformsTo(T, Interfaces...)
> {
> enum conformsTo = AdaptTo!Interfaces.hasRequiredMethods!T;
> }
>
> and use it like this
>
> void draw(T)(T shape) if (conformsTo!(T, Shape, Drawable))
>
> This will of course only work for methods, not properties or aliases,
> so you still need constraints in some cases.
That's nice, thank you.
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list