Deterministic life-time storage type

Christophe Travert travert at phare.normalesup.org
Sat Apr 21 23:41:46 PDT 2012


Michel Fortin , dans le message (digitalmars.D:164824), a écrit :
> So with your system, how do you write the swap function?

I've thought about that.
The scope(label) is the key.

void T swap(T)(scope T a, scope(a) T b)
{
  scope(a) tmp = a;
  a = b;
  b = tmp;
}

scope(inout) would also do the trick, since it is implicitely shared 
between parameters and return values.

-- 
Christophe


More information about the Digitalmars-d mailing list