Possible way to achieve lazy loading with const objects

Steven Schveighoffer schveiguy at yahoo.com
Wed Sep 28 08:43:48 PDT 2011


On Wed, 28 Sep 2011 10:52:24 -0400, Kagamin <spam at here.lot> wrote:

> Jonathan M Davis Wrote:
>
>> Some programmers have expressed annoyance and/or disappointment that  
>> there is
>> no logical const of any kind in D.
>
> isn't it trivial?
>
> void setConst(T1,T2)(ref T1 dst, in T2 src)
> {
>   *cast()&dst=src;
> }
>
> const int v;
> setConst(v,5);
> assert(v==5);

Trivial, and also undefined behavior ;)

-Steve


More information about the Digitalmars-d mailing list