How to dispatch a class function for an object accessed by handle?
wjoe
invalid at example.com
Fri Mar 6 11:51:54 UTC 2020
On Thursday, 5 March 2020 at 18:33:41 UTC, Adam D. Ruppe wrote:
> On Thursday, 5 March 2020 at 14:24:33 UTC, wjoe wrote:
>
> [...]
>
> template opDispatch(string name) {
> auto opDispatch(T, Args...)(Args args) {
> ...
> }
> }
>
> [...]
>
>
> NOTE: opDispatch suppresses internal compile errors, it will
> just say "no such property whatever". you can explicitly
> instantiate with `f.opDispatch!"whatever` to help see better
> errors.
>
Follow-up question:
Calling f.whatever!SomeResource(...); works no problem.
However I can't figure out how to call a function by explicitly
instantiating opDispatch.
Since f.opDispatch!"load"(handle, "wallpaper.png");
doesn't compile, I refreshed my memory about the shortcut syntax
and the eponymous syntax and the way I read it is that this is a
template of a template.
So I tried this: f.opDispatch!"load".opDispatch!Bitmap(handle,
"path/to/wallpaper.png");
But this doesn't compile either and errors out with:
Error: Cannot resolve type for f.opDispatch(T,
ARGS...)(ResourceHandle handle, ARGS args)
I don't understand this error message. Which type can't be
resolved?
Is there a way to look at output of what the compiler generates
for f.whatever!SomeResource(...); ?
More information about the Digitalmars-d-learn
mailing list