question...
Daniel919
Daniel919 at web.de
Wed Jan 9 04:03:34 PST 2008
> void main() {
> class A {}
> static assert(is( typeof(new A) == typeof(A)) ); // 1
> static assert(is( typeof(new int*) == typeof(int*) )); // 2
> }
>
> First assert compiles, but the second one not.
It's because of the difference that
- classes are reference types
- basic data types and structs are value types
These are working:
//reference type
class A {}
static assert(is( typeof(new A) == A ));
//value type
struct B {}
static assert(is( typeof(new B) == B* ));
static assert(is( typeof(new int) == int* ));
static assert(is( typeof(new int*) == int** ));
More information about the Digitalmars-d-learn
mailing list