[Semi-OT] to!string(enumType)
Dominikus Dittes Scherkl via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 19 10:34:28 PDT 2017
On Friday, 19 May 2017 at 00:14:05 UTC, Stefan Koch wrote:
> string enumToString(E)(E v)
> {
> static assert(is(E == enum),
> "emumToString is only meant for enums");
Why that assert? We can check it at compiletime. Doesn't this cry
for a constraint? I would use asserts only ever for stuff that's
only known at runtime.
string enumToString(E)(E v) if(is(E == enum))
{
...
}
More information about the Digitalmars-d
mailing list