Templates for DRY code

Paul Backus snarwin at gmail.com
Sat Jan 6 23:32:42 UTC 2018


On Saturday, 6 January 2018 at 03:38:35 UTC, codephantom wrote:
> or even..
>
> a.append( s.to!ConvertToElementType(a) );
>
> That's not valid code of course, but the semantics are all 
> contained in that single chunk.

This works:

import std.range.primitives: ElementType;

a ~= s.to!(ElementType!(typeof(a)));


More information about the Digitalmars-d-learn mailing list