Filter for opDispatch?
Paul Backus
snarwin at gmail.com
Fri May 14 22:52:40 UTC 2021
On Friday, 14 May 2021 at 22:39:29 UTC, frame wrote:
> When using opDispatch()
>
> - how can I tell the compiler that I do not want to handle some
> calls? Some code is testing for range methods (empty, front,
> popFront) and I don't know where and which side effects it
> causes.
Use a template constraint. For example:
auto opDispatch(string method, Args...)(Args args)
if (shouldHandle!method)
{
// ...
}
...where `shouldHandle` checks the method name and returns `true`
if you want to handle it, or `false` if you don't.
> - how can I dismiss calls from __traits(compiles)?
You can't.
More information about the Digitalmars-d-learn
mailing list