Oleg:

at compile time i have errors
./recursion.d(7): Error: index 4294967295 overflow for static array ./recursion.d(7): Error: index 4294967294 overflow for static array
.... etc

It prints a little too many of those...


call 'recursionAlgo()' where it should not be ( K == 1 )

The first problem to fix in your code is visible here, it's not a CTFE problem:


struct MyStruct(uint K) {
    real[K] data;

    auto getSmaller() {
        MyStruct!(K - 1) ret;
    }
}

void main() {
    MyStruct!5 a;
}


When you instantiate MyStruct!5, it tries to define ret, so it instantiates MyStruct!4, MyStruct!3, ... and so on. You have to put a static if or something else to stop that.

Bye,
bearophile

Reply via email to