[phobos] phobos commit, revision 2181
spir
denis.spir at gmail.com
Fri Nov 19 13:20:13 PST 2010
On Fri, 19 Nov 2010 09:18:47 -0800
Andrei Alexandrescu <andrei at erdani.com> wrote:
> On 11/19/10 2:22 AM, spir wrote:
> > Hum, is this really a transgression of const's promise? Each object's .name fields remains unchanged as expected. Rather only the symbolic relations (var-id<--> object) change. It's another kind of change.
> > Here, the 2 facts that the fields are called 'name' and that they hold values equal to var-ids, commonly called 'name' as well, just introduce confusion.
> > What about this, is it also inacceptable?
> >
> > struct S
> > {
> > const uint code;
> > }
> > auto a = S(1); // a<--> obj1 (code:1)
> > auto b = S(1); // b<--> obj2 (code:2)
> >
> > swap(a, b);
> > assert(a.code == 2); // a<--> obj2 (code:2)
> > assert(b.code == 1); // b<--> obj1 (code:1)
>
> A const field is expected to always stay the same after being set.
The field here is left unchanged.
denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the phobos
mailing list