mutable reference to const object
Vadim Lopatin
coolreader.org at gmail.com
Thu Mar 6 09:40:32 PST 2014
On Thursday, 6 March 2014 at 15:59:12 UTC, bearophile wrote:
> Vadim Lopatin:
>
>> In C++, following code works as I'm expecting:
>
> Different language, different (hopefully better) semantics. In
> D const and immutable are transitive, this means they make
> const/immutable the whole sub-tree of data they refer to:
> http://dlang.org/const3.html
>
> Bye,
> bearophile
Const sub-tree is object itself and its data.
Reference to object is outside of tree.
Why references to const object should be const?
Such references cannot be used to modify object anyway.
More information about the Digitalmars-d-learn
mailing list