On Saturday, 1 June 2019 at 14:24:11 UTC, Robert M. Münch wrote:

The myFilter struct is the implementation which myClass.put() should use to iterate over all objects.

Which ones? The E-objects, or the objects contained in myClass, which you don't want to know about?

All things being only examples.

Sure. So, please, provide a minimal example, as I'm only guessing what use case you want to solve. Even if it is not compilable.

So, the idea is, that I can provide a delegate which foreach(...; myFilter(objects)) uses. Like a run-time plug-in.

Maybe you can. But "put" has to remain a function, not a template.


Do you have control about the contained classes? If so, it is a hint to implement the testing inside them. Like:

/* probably inside a templated mixin */
bool testfunction(inputs){...}

class myOtherClass(/*probably templated*/){... mixin testfunction ... & provide a put function}

I thought about a mixin too. But this requires an understanding of how myClass works. Which I what I want to avoid.

Over which objects your filter will be iterating then?

* So, you are not totally against the idea of modifying the foreign library, but you want to keep modifications small?

Yes, because myClass is some external lib, which can be changed to support this approach here. But not more.

Reply via email to