What guarantees does D 'const' provide, compared to C++?
Chris Cain
clcain at uncg.edu
Thu Aug 16 18:33:28 PDT 2012
Just to be abundantly clear about his point.
// v is a const vector, but holds pointers ...
*v[0] = 5; // legal in C++, illegal in D (except in constructors
which will allow this, ATM)
Transitivity gives you more information and guarantees about what
you can and can't do with your view. Also, if the only view of
the data you have is that const view, it's effectively the same
as immutable (it couldn't be changed by any valid code).
More information about the Digitalmars-d
mailing list