A const idiom + a different 'delete'

Kagamin spam at here.lot
Wed Aug 11 22:38:10 PDT 2010


bearophile Wrote:

> void main() {
>     int[int] aa_;
>     foreach (i; 0 .. 10)
>         aa_[i] = i * i;
> 
>     // now I'd like to freeze aa
>     const(int[int]) aa = aa_;
> }
> 

void f()
{
  {
    int[int] aa;
    //fill
    g(aa);
  }
  void g(ref const int[int] bb)
  {
    //do stuff
  }
}


More information about the Digitalmars-d mailing list