enum overloading

strtr strtr at spam.com
Sun May 23 07:31:14 PDT 2010


----
module e2_def;

import std.string;

static enum ENUM_2 { D, E, F };

char[] toString(ENUM_2)
{
	return "ENUM_2";
}
--
module main;
import std.string : toString;
import std.stdio;
import e2_def : ENUM_2, toString;

enum ENUM { A,B }

char[] toString(ENUM e_){return "ENUM";}

void main (){
	writefln( toString(3) );
	writefln( toString(ENUM.A) );
	writefln( toString(ENUM_2.D) );
}
----
3
ENUM
ENUM_2

Yep seems to work like that.


More information about the Digitalmars-d-learn mailing list