On Tuesday, 11 November 2014 at 19:23:39 UTC, Adam Taylor wrote:
Now what i want to do is pass some such "container" object to
an interface function:
interface MyInterface
{
void filterCollisions(S)(S collisionCandidates)
if(canRemoveFromContainer!S)
}
You can't. This is one of the major restrictions of the template
approach. Generics in C# allow for this, which I believe is
reliant its JIT compiler.
Once you introduce the need for a vTable (which interfaces do) it
is no longer possible to require implementation of a "phantom"
function. Templates don't exist until their use, so it is not
possible to require an entry in the vTable when the number of
possible combinations is infinite.