Re: Declaring constant references in struct members

2017-02-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 16 February 2017 at 01:05:58 UTC, David Zhang wrote: Is there a similar mechanism for one struct holding another? You'd have to make the member a pointer to the struct. immutable(B)* b;

Re: Declaring constant references in struct members

2017-02-15 Thread David Zhang via Digitalmars-d-learn
On Thursday, 16 February 2017 at 00:49:45 UTC, Adam D. Ruppe wrote: On Thursday, 16 February 2017 at 00:43:30 UTC, David Zhang wrote: struct S { O object; } import std.typecons; Rebindable!O object; http://dpldocs.info/experimental-docs/std.typecons.Rebindable.html Is there a similar

Re: Declaring constant references in struct members

2017-02-15 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 16, 2017 at 12:43:30AM +, David Zhang via Digitalmars-d-learn wrote: > Hi, > > Say I have a struct S that holds a reference to an object O. Is there > a way to express that I want to be able to change the reference, but > not what the reference points to? Thanks. > > struct S {

Re: Declaring constant references in struct members

2017-02-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 16 February 2017 at 00:43:30 UTC, David Zhang wrote: struct S { O object; } import std.typecons; Rebindable!O object; http://dpldocs.info/experimental-docs/std.typecons.Rebindable.html

Declaring constant references in struct members

2017-02-15 Thread David Zhang via Digitalmars-d-learn
Hi, Say I have a struct S that holds a reference to an object O. Is there a way to express that I want to be able to change the reference, but not what the reference points to? Thanks. struct S { O object; } class O { size_t things. }