On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote: > On 08/04/2012 11:09 PM, Jonathan M Davis wrote: > > I agree that an enum's base type should not implicitly convert to the enum > > type, since that would mean that you could have an invalid enum value, but > > I see no problem with enums implicitly converted to their base type. > Well, there is a problem: > > T fun(T)(T arg) if(isSomeString!arg){ > return arg~arg[0]; > } > > The constraint would be too weak.
True, but that's still going to cause a lot fewer problems than making isSomeString fail for enums will, and if auto is used, then it's not a problem. Though honestly, I'd argue that the compiler should treat arg ~ arg[0] as being string rather than the enum type anyway, since it makes no sense to get a new enum value by concatenating to an existing one. The new one probably isn't a valid enum value. It's the same problem that we get when we allow bit manipulation on enum types (which should also be disallowed IMHO). So, I think that that's more of a problem with enums than isSomeString. - Jonathan M Davis