Templates for DRY code
Mark
smarksc at gmail.com
Tue Jan 9 00:47:05 UTC 2018
On Saturday, 6 January 2018 at 23:32:42 UTC, Paul Backus wrote:
> 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)));
I think you can just do:
s.to!(typeof(a[0]));
More information about the Digitalmars-d-learn
mailing list