What's wrong with my usage of std.algorithm.map in this code example?
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed May 25 07:32:11 PDT 2016
On 05/25/2016 03:27 PM, Chris wrote:
> Why can the tuple be iterated with foreach, as in my quick fix, and
> indexed with tuple[0..], but is not accepted as a range? What are the
> differences?
popFront doesn't make sense with a tuple (aka expression list). When you
remove the first element of a tuple, you get another tuple of a
different type, but popFront can't change the type of the range.
In code:
----
void main()
{
import std.meta: AliasSeq;
AliasSeq!(int, int, int) tuple = AliasSeq!(1, 2, 3);
tuple.popFront(); /* How would this be implemented? Would have to
change tuple's type to AliasSeq!(int, int). */
}
----
> Is there a way to rangify a tuple?
std.range.only:
----
void main()
{
import std.meta: AliasSeq;
import std.range: only;
AliasSeq!(int, int, int) tuple = AliasSeq!(1, 2, 3);
auto range = only(tuple);
range.popFront(); /* ok */
}
----
More information about the Digitalmars-d-learn
mailing list