Is it possible to modify a const field of a non-const object (using const_cast) in C++20?
Yes, I know it probably shouldn't be allowed, and that there are very similar questions (Move construction and assignment of class with constant member, Replace a variable of a type with const members). But some answers and comments seem to suggest that it's possible in C++20; but I can't find anything that clearly says it's allowed.
For example:
As of c++20 you can modify a const member object. There's even a constexpr function to do so,
construct_at
and well asdestroy_at
in case the the object has a non-trivial dtor. – doug Apr 14
(comment to https://stackoverflow.com/a/68018681/8245776)
As well as this answer (https://stackoverflow.com/a/71805401/8245776), which I honestly don't really understand, but it seems to be saying that it is possible in C++20.
So is it possible to do this in C++20, or am I misunderstanding those answers?
Edit:
Ok so, judging from the mentioned questions, I think the answer is that it's possible in C++20? I'm still not sure though, so if anyone could confirm this, that would be appreciated.