On Monday, 15 November 2021 at 08:38:07 UTC, Ola Fosheim Grøstad wrote:
>The reason you can cast away const is so that you can call C-APIs that actually have const-behaviour, but not a const signature.
Also note that objects that are created as const should not be modified, quoting cppreference:
«const object - an object whose type is const-qualified, or a non-mutable subobject of a const object. Such object cannot be modified: attempt to do so directly is a compile-time error, and attempt to do so indirectly (e.g., by modifying the const object through a reference or pointer to non-const type) results in undefined behavior.»