3 ms·
You're right, C++ generic implementation is different than Java for example. That's why it was hard for me to nail the features the generic should have in gener
by p0w3n3d 10mo ago
You're right, C++ generic implementation is different than Java for example. That's why it was hard for me to nail the features the generic should have in general... C++ is more like duck typing with precompiled checking i.e. If you have no traits you still get integers summed for example because the generated code from the headers is compilable. On Java it's different: all the generics have types erased and there is typecasting later, unless they are inherited by other types
- mikepurvis 10mo agoI'm not a Java person, but my understanding is that in Java everything is boxed anyway, so the implementation of the "generic" logic is always just dealing with a pointer-sized entity and it's a matter of whether the dereferenced object on the other end of that has the required fields/methods.
- renox 10mo ago> Java everything is boxed anyway Not true, there's int and Integer.
- mikepurvis 10mo agoRight but you can’t use them as type arguments to Java’s generics so they’re not really relevant in this context.