contracts in interfaces

Yann skratchie at gmx.de
Thu Dec 13 05:05:14 PST 2012


Hi,

could someone tell me what the problem(s) with the following are? 
Also, how do I make "$" work with the slice operator?

Thanks a lot.

interface Graph
{
   bool opIndex(uint u, uint v)
   in { assert(u < n && v < n); }

   Graph opSlice(uint start, uint end)
   in { assert(start < n && end <= n); }
   //why does this not compile:
   out(g) { assert(g.n == end - start); }

   @property uint n();
}

interface MutableGraph : Graph
{
   bool addEdge(uint u, uint v)
   in { assert(u < n && v < n); }
   //why does this produce a segmentation fault when executed:
   out(ret) { assert(this[u,v]); }
}


More information about the Digitalmars-d-learn mailing list