Re: How to get BaseEnumType?

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 11:12, Enamex wrote: On Monday, 31 August 2015 at 07:55:53 UTC, drug wrote: Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo ==

Re: How to get BaseEnumType?

2015-08-31 Thread wobbles via Digitalmars-d-learn
On Monday, 31 August 2015 at 07:55:53 UTC, drug wrote: Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo == string)); static assert(is(BaseEn

Re: How to get BaseEnumType?

2015-08-31 Thread Enamex via Digitalmars-d-learn
On Monday, 31 August 2015 at 07:55:53 UTC, drug wrote: Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo == string)); static assert(is(BaseEn

Re: How to get BaseEnumType?

2015-08-31 Thread wobbles via Digitalmars-d-learn
On Monday, 31 August 2015 at 08:10:35 UTC, wobbles wrote: On Monday, 31 August 2015 at 07:55:53 UTC, drug wrote: import std.stdio; import std.traits; void main(){ static if(isSomeString!Foo){ writefln("String: %s", Foo.A); } static if(isScalarType!Bar){

Re: How to get BaseEnumType?

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 11:10, wobbles wrote: In std.traits there is the required isX funcitons. import std.stdio; import std.traits; void main(){ static if(isSomeString!Foo){ writefln("String: %s", Foo.A); } static if(isScalarType!Bar){ writef

How to get BaseEnumType?

2015-08-31 Thread drug via Digitalmars-d-learn
Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo == string)); static assert(is(BaseEnumType!Bar == int)); I guess there is simple answer som