On Wednesday, 17 February 2016 at 19:03:25 UTC, Jonathan M Davis
wrote:
As soon as you start using pointers or containers or pointers
or anything like that, pretty quickly, you can get situations
like where the container is const, but its elements aren't.
Yes, generic containers is an issue in C++. You can't just recast
the template parameter as const, as the internals could depend on
it not being const when the container was instantiated (if-test
on const in the constructor). This is a problem we get when
meta-programming becomes powerful enough.
The easy way out is to use a wrapper and implement the constness
in the wrapper (a class with just a pointer and methods).
Basically implement a reference type for container access.