3 ms·
In what scenario would this be useful? If foo() takes a struct A, it should be more generic and have no knowledge about the more specialized struct B.
by teo_zero 1y ago
In what scenario would this be useful? If foo() takes a struct A, it should be more generic and have no knowledge about the more specialized struct B.
- 1718627440 1y agoIn exact that same scenario, that you would cast to a subclass in another language, it's about language support for what for example the kernel does with container_of. Of course casting to a subclass isn't guaranteed to succeed always, but for example when you have actually declared it as the subclass elsewhere it's fine without checking for isinstance.