|
|
|
|
|
by trinovantes
1838 days ago
|
|
Most of the time, factories or IIFE would be sufficient. Sometimes the non trivial stuff is non deterministic, requires other sources of input, or gives up cpu control that makes them insufficient for all use cases. Also, my problem with const pointers is that they don't enforce deep immutability and can cause all sorts of compilation errors if I try to pass them to non-const functions (usually to external libraries). Then I'd end up type casting my pointers which defeats the purpose of static type checking. |
|
I'd also add even if you thought you could enforce this at runtime, in practice it wouldn't really work due to pointer aliasing.