> Why would is(T == struct) be true but !isBuiltinType!T be false? Exactly because of alias this. Your type is a struct and an integer at the same time, so to speak. At least it behaves that way and that's what its all about. If if looks like a duck, quacks like a duck, ... it is a duck ;-) > This seems highly inconsistent. If T is a struct, it is not a > builtin type, and if T is int (also making the condition false), > then Property should never have been passed as a struct, but as > the int gotten via the alias.
Your struct is both at the same time, it stops being both as soon as it is copied to a function argument expecting an int, but not any sooner. It is always passed as the struct, that's also what you are doing: You pass the struct to writefln. It only allows being treated as an int, which also means it can be copied to an int argument of a function. But this happens even later in the call chain, the above mentioned function is also a template, so it sees the struct not the naked int, but it does the expected thing because of the seemingly contradictory checks. So another overload is used, which expects builtin types. With your alias this your struct is a struct and a builtin at the same time. Without the alias this feature, you would be right that the check makes no sense.