Re: Template variable not reach at compile

2018-07-21 Thread Greatsam4sure via Digitalmars-d-learn
On Saturday, 21 July 2018 at 13:13:11 UTC, Mike Parker wrote: On Saturday, 21 July 2018 at 12:17:54 UTC, Greatsam4sure wrote: Sorry for the typo. This is the problem auto arithmetic(T, V, U)(T a, V b, U op){ return mixin("a"~op~"b"); } //call like this arithmetic(1.5,2.5,"+"); Compiler

Re: Template variable not reach at compile

2018-07-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 July 2018 at 12:17:54 UTC, Greatsam4sure wrote: Sorry for the typo. This is the problem auto arithmetic(T, V, U)(T a, V b, U op){ return mixin("a"~op~"b"); } //call like this arithmetic(1.5,2.5,"+"); Compiler says the variable op is not reach at compile time. So how ca

Re: Template variable not reach at compile

2018-07-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/07/2018 12:15 AM, Greatsam4sure wrote: auto arithmetic(T, V, U)(T a,  V b,  U op){    return mixin("a"~op~"b"); } //call like this arithmetic(1.5,2.5,"op"); Compiler says the variable op is not reach at compile time.  So how can the varible a and b be reach at compile time and op is no

Template variable not reach at compile

2018-07-21 Thread Greatsam4sure via Digitalmars-d-learn
Sorry for the typo. This is the problem auto arithmetic(T, V, U)(T a, V b, U op){ return mixin("a"~op~"b"); } //call like this arithmetic(1.5,2.5,"+"); Compiler says the variable op is not reach at compile time. So how can the varible a and b be reach at compile time and op is not rea

Template variable not reach at compile

2018-07-21 Thread Greatsam4sure via Digitalmars-d-learn
auto arithmetic(T, V, U)(T a, V b, U op){ return mixin("a"~op~"b"); } //call like this arithmetic(1.5,2.5,"op"); Compiler says the variable op is not reach at compile time. So how can the varible a and b be reach at compile time and op is not reach. I will appreciate any help. I have al