On Friday, 4 December 2015 at 18:21:41 UTC, Walter Bright wrote:
I suggested in the pseudo namespaces thread using template parameters to express characteristics, as in:

    remove!(stable, linear)

with sensible defaults so most of the time the user would just use:

    remove

The nice thing about this is that it can be easy to specify which complexities an operation supports.

---

void remove(complexity, T)(List!T list, size_t index) if(complexity >=
    Complexity.linear); //or however complexity objects work...

List l;
//...
l.remove(3);
l.remove!(Complexity.polynomial(2))(3);
l.remove!(Complexity.constant)(3);//fails; there's no template specialization for this case because complex < linear.


Reply via email to