construct range from tuple?

e-y-e via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Sep 18 02:38:21 PDT 2016


On Sunday, 18 September 2016 at 09:36:13 UTC, e-y-e wrote:
> On Sunday, 18 September 2016 at 08:06:54 UTC, Lutger wrote:
>> [...]
>
> Use std.range's 'only' function [1], it takes variadic 
> arguments of the same type and constructs a range consisting of 
> them.
>
> Example:
>
>     import std.meta : AliasSeq;
>     import std.range : only;
>     import std.algorithm.comparison : equal;
>
>     alias names = AliasSeq!("Alice", "Bob");
>
>     auto range = only(names, "Chuck");
>     assert(range.equal(["Alice", "Bob", "Chuck"]));

[1] https://dlang.org/phobos/std_range.html#only


More information about the Digitalmars-d-learn mailing list