Explicit casting of enum -- intentional restriction?

rcorre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 1 13:52:48 PDT 2016


I just tried to compile an old project and the following failed:

---
enum Paths : string {
   bitmapDir     = "content/image",
   fontDir       = "content/font",
   soundDir      = "content/sound",
...

if (Paths.preferences.exists)
     ...
---

It turns out members of Paths are no longer implicitly converted 
to string, and I needed to use

if ((cast(string)Paths.preferences).exists)

Is this an intentional limitation or a regression? I didn't see 
it in the last few changelogs but I'll admit I didn't check them 
rigorously.


More information about the Digitalmars-d-learn mailing list