On Thursday, 28 June 2018 at 17:00:37 UTC, Mr.Bingo wrote:
I mean, if you think about it, the memory layout of a tuple is
sequential types:
T1
T2
...
So, to popFront a tuple is just changing the starting offset.
You're right; it can definitely be done.
struct TupleRange(T...)
{
size_t index;
Tuple!T store;
@property length()
{
assert(index <= store.length);
return store.length - index;
}
Algebraic!T front()
{
assert(length > 0);
return typeof(return)(store[index]);
}
void popFront()
{
assert(length > 0);
index++;
}
}