CTFE Status 2
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Sat Mar 11 06:39:54 PST 2017
On Thursday, 16 February 2017 at 21:05:51 UTC, Stefan Koch wrote:
> [ ... ]
Basic Slicing support is in;
The following code will now compile with the newCTFE_slicing
branch:
static immutable uint[] OneToTen = [1,2,3,4,5,6,7,8,9,10];
const(uint[]) SliceOf1to10(uint lwr, uint upr) {
return OneToTen[lwr .. upr];
}
static assert(SliceOf1to10(2,8) == [3u, 4u, 5u, 6u, 7u, 8u]);
Contrary to the old interpreter no copies are made.
newCTFE slices reference memory just as runtime slices do.
Cheers, Stefan;
More information about the Digitalmars-d
mailing list