The evils of __traits(compiles)

jmh530 john.michael.hall at gmail.com
Thu Jan 21 22:09:46 UTC 2021


On Thursday, 21 January 2021 at 21:42:19 UTC, Paul Backus wrote:
> [snip]
>
> This is also a great illustration of the pitfalls of using 
> __traits(compiles) without thorough unit testing, because your 
> code has a bug in it that isn't covered by your tests:
>
>     static assert(isAddable!(inout(int))); // fails

The code as it is used in the library requires isMutable!T before 
T gets passed into that logic.

However, I still think it's weird. Changing inout to const or 
immutable works. I never would think to use inout(int) that way...


More information about the Digitalmars-d mailing list