Problem with type cast in if condition
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Oct 6 13:37:21 PDT 2015
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 different code to
be compiled based on the condition - meaning types can change too.
More information about the Digitalmars-d-learn
mailing list