Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
So I went on a walk and thought about this some more. I can see this being useful if you have a private class vs a public class. As long as you ensure the data sizes match and the variables match you should be able to create interchangeable objects with different methods available depending upon context. This could be hazardous to maintain though.
-
@Demolishun
https://en.m.wikipedia.org/wiki/...
Important to read... Undefined behaviour can be pretty annoying. -
@IntrusionCM yeah, I saw that. cppreference has a better explanation. I am trying to fathom why the compiler isn't enforcing this. Either it is hard to catch or it is actually useful in some contexts.
-
atheist99291y@Demolishun the compiler can't enforce it unless one compilation unit includes both declarations. If you're only using forward declarations, no help there. The linker might be able to catch it, but that's not so straight forward. The same object can correctly be declared in multiple compilation units, part of what a linker does is spots that and removes the duplication.
-
Voxera115851y@Demolishun yes, and someone will have (ab)used that todo some conversion do changing it will be a breaking change, hence very very hard to get accepted.
-
@jassole
Problem with c++ is that the language evolves faster than the adoption, particularly for multi platform projects due to differences in speed of feature adoption (looking at you msvc, tho they have improved drastically lately).
Also the massive support codebase which could take ages to update. -
@jassole we are mostly still on C++11. I have one project I am compiling with C++17. Now I have to backport it to an older compiler to support an older system. Not looking forward to that.
-
@Demolishun
Fortunately, boost does a very decent job at backporting most modern features to older versions.
Related Rants
C++ type fuxor we found by accident in our code. I am not upset about allowing 2 different types to have the same type name. I am upset that the compiler thinks they are the same type and allows pointer assignment. I didn't know you could fool the compiler this way. I suppose this might be useful if the types are in sync. But damn, this is kinda fucked.
rant
fuxor
bullshit
type