Re: Problem with type cast in if condition

2015-10-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 20:35:28 UTC, NiRu wrote: if(is(typeof(value) == User)){ Use `static if` instead of plain `if` here. Regular if does a runtime branch, so both true and else branches must compile with the same types. Static if does a compile time branch, allowing differ

Problem with type cast in if condition

2015-10-06 Thread NiRu via Digitalmars-d-learn
Hi there, I have a problem with the typecast within my if condition, the dmd2 compiler says he can not cast int to User, but it never reaches an int type the condition (at most, the else branch). my try: struct User { string name; } void printName(T)(T value) { if(is(typeof(