Graham St Jack wrote:
I have been trying (again) to start using const and immutable objects in
a project, and found I kept getting stuck with the need to change the
value of object references, which isn't allowed. I don't quite follow the
arguments that mean that this has to be the case, but I'm prepared to
accept them.
After some experimenting with Andrei's Rebindable template, I still
couldn't get past the problems. For a start, the get method is private so
I couldn't test for null.
In the end I cooked up the following, which is a very simple workaround
that just lets me assign to a const or immutable object reference. It
works just fine, and can be used in templates like containers without
forcing the container to care about what it is containing.
Comments?
[snip code]
Hi Graham,
Could you please post a short snippet (or a few) that illustrate the
problems you ran into with Rebindable?
Thanks,
Andrei