readonly?

Timon Gehr timon.gehr at gmx.ch
Tue Jul 10 16:45:13 PDT 2012


On 07/11/2012 12:58 AM, Ali Çehreli wrote:
> On 07/10/2012 03:53 PM, Namespace wrote:
>>> const(T)* ?
>>
>> Example?
>
> class Bar
> {}
>
> class Foo
> {
>      const(Bar) * _b;
>
>      void SetBar(const(Bar) * b) {
>          _b = b;
>      }
> }
>
> void main()
> {
>      auto b = new Bar();
>      auto f = new Foo();
>      f.SetBar(&b);
> }
>
> Ali

This escapes a stack reference.


More information about the Digitalmars-d-learn mailing list