www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Request: is(typeof(X.init) == X) for all X

reply Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
Hi,

The subject says it all. This is currently not true for static arrays:

template test(X) {
   static assert(is(typeof(X.init) == X));
}

struct T{}

mixin test!(int);
mixin test!(int *);
mixin test!(void delegate());
mixin test!(void function());
mixin test!(Object);
mixin test!(T);
mixin test!(T*);
mixin test!(char[]);
mixin test!(char[5]);

Gives:

init.d(2): static assert  (is(char == char[5])) is false

/Oskar
May 05 2006
parent Bruno Medeiros <brunodomedeirosATgmail SPAM.com> writes:
Oskar Linde wrote:
 Hi,
 
 The subject says it all. This is currently not true for static arrays:
 
 template test(X) {
   static assert(is(typeof(X.init) == X));
 }
 
 struct T{}
 
 mixin test!(int);
 mixin test!(int *);
 mixin test!(void delegate());
 mixin test!(void function());
 mixin test!(Object);
 mixin test!(T);
 mixin test!(T*);
 mixin test!(char[]);
 mixin test!(char[5]);
 
 Gives:
 
 init.d(2): static assert  (is(char == char[5])) is false
 
 /Oskar
 

That would be nice, as would be other changes to static arrays "alien type" behaviour. -- Bruno Medeiros - CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
May 07 2006