Introduction to programming with compile time sequences in D
data pulverizer
data.pulverizer at gmail.com
Tue Aug 25 15:25:38 UTC 2020
On Tuesday, 25 August 2020 at 14:02:33 UTC, Petar Kirov
[ZombineDev] wrote:
> Nice article! I haven't had the chance to read it fully, so far
> now I have just one quick suggestion regarding removing items
> from sequences [0]. I think it would be much simpler (and
> likely more efficient) to avoid both recursion and static
> foreach and simply use slicing + concatenation. Here's an
> example:
>
> template removeFromSeqAt(size_t idx, seq...)
> {
> static if (seq.length > 0 && idx < seq.length)
> alias removeFromSeqAt = AliasSeq!(seq[0 .. idx], seq[idx +
> 1 .. $]);
> else
> static assert (0);
> }
>
> You can find a full example of this here:
> https://run.dlang.io/gist/run-dlang/80e120e989a6b0f72fd7244b17021e2f
>
>
> [0]:
> https://gist.github.com/dataPulverizer/67193772c52e7bd0a16414cb01ae4250#removing-items-from-a-compile-time-sequence
I could probably apply the same thing to some if not all the
other template operations. Many Thanks!
More information about the Digitalmars-d-announce
mailing list