On Wednesday, 5 August 2020 at 09:39:47 UTC, Simen Kjærås wrote:
On Wednesday, 5 August 2020 at 09:32:58 UTC, Flade wrote:
Thanks! You see it should work but the thing is. I'm using it inside a function. I'm checking for one of the function's parameter (if parameter == false) and it says that "the variable `parameter` cannot be read at compile time. Do you know if there is a way to fix this?

As the error message says, the value must be known at compile time. Most likely, you can simply pass it as a template parameter:

    void fun(bool parameter)(int arg1, string arg2) {
        static if (parameter) {
        }
    }

    void main() {
        fun!true(1, "foo");
        fun!false(19, "bar");
    }

--
  Simen

Thanks man! Works as expected! Have a great day!

Reply via email to