On Wednesday, 20 September 2017 at 12:01:21 UTC, Nordlöw wrote:
When is__traits(compiles, { ... } ) preferred over is(typeof( { ... } )) and vice versa when writing stuff likeenum isCopyable(S) = is(typeof( { S foo = S.init; S copy = foo; } ));?Further, are there cases where the two idioms aren't exchangable?
Yes there are.Prefer __traits(compiles) it includes stricter visibility checks then is() does. Also compiles does not require the expression to resolve to a type.