Solution to "statement is not reachable" depending on template variables?

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 16 21:04:05 PDT 2016


On 17/03/16 5:05 AM, Johan Engelen wrote:
> On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole wrote:
>>
>> Change those static if's to just plain old ifs.
>
> But then this wouldn't compile, would it?
> ```
> static if(__traits(compiles, __traits(getMember, a, "b"))) {
>     return a.b;
> }
> ```
> (real code, I am not making this up)

Hmm no.
If that's in a foreach as well, you'll need to solve it some other way.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the Digitalmars-d-learn mailing list