3 ms·
With reified generics, the code class Foo<X> { X x; } Foo<int> fooInt; fooInt.x = 5; Foo<float> fooFloat; fooFloat.x = 5.0; compiles to: c
by meindnoch 1y ago
With reified generics, the code
class Foo<X> {
X x;
}
Foo<int> fooInt;
fooInt.x = 5;
Foo<float> fooFloat;
fooFloat.x = 5.0;
compiles to:
class Foo_int {
int x;
}
class Foo_float {
float x;
}
Foo_int fooInt;
fooInt.x = 5;
Foo_float fooFloat;
fooFloat.x = 5.0;
On the other hand, erased generics compiles to this:
class Foo {
void* x;
}
Foo fooInt;
fooInt.x = new int(5);
Foo fooFloat;
fooFloat.x = new float(5.0);