On Monday, 17 December 2012 at 09:42:50 UTC, maarten van damme wrote:
I finally got around trying to finish my sudoksolver and I'm pretty happy with the result, except one little piece that screams for ctfe
but I never seem to get it working.
I always get "variable x cannot be read at compile time" in this method :

auto bitsetToRange(in SudokuCell x) {
return boardSide.iota().filter!(i => (x >> i) & 1)().map!(x=>x+1)();
}

with SudokuCell beeing declared as:
alias ushort SudokuCell;

I want to generate a dynamic array with all return values form this
method with x ranging from 0..sudokuCell.size.
Why is it complaining x cannot be read at compile time while it is
passed at compile time?

Probably because you declared "boardside" as an "auto"? You need to declare it as immutable or enum. Can't add much to it without some context.

FYI: As much as I love ufcs, "boardSide.iota()" makes no sense to me. It took me a minute to realize what was going on. I'd really write it as: return iota(boardSide).filter!(i => (x >> i) & 1)().map!(x=>x+1)();

Reply via email to