Figuring out the returntype opDipatch

Jacob Carlborg doob at me.com
Sun Nov 3 02:48:44 PST 2013


On 2013-11-03 03:15, TheFlyingFiddle wrote:

> In the IReflectionable interface:
>
> interface IReflectionable
> {
>      final P funcPtr(P)(string fun) if (is(P == delegate))
>      {
>          //Using mangeling for overloads and type safety
>      auto ptr = delPtr_impl(mangle!P(fun));
>
>      P del;
>      del.ptr = cast(typeof(del.ptr))ptr[0];
>      del.funcptr = cast(typeof(del.funcptr))ptr[1];
>      return del;
>      }
>
>      final P funcPtr(P)(string fun) if (is(P == function))
>      {
>          //Using mangeling for overloads and type safety
>      auto ptr = funcPtr_impl(mangle!(P)(fun));
>      return cast(P)ptr;
>      }
>
>      final ?? opDispatch(string name, Params...)(Params params)
>      {
>         alias ?? delegate(Params) del_type;
>         auto del = funcPtr!(del_type)(name);
>
>         static if(?? == void)
>            del(params);
>         else
>            return del(params);
>      }
>
>      protected Tuple!(void*, void*) delPtr_impl(string s);
>      protected void* funcPtr_impl(string s);
> }
>
> What i'm interested in is determining what type ?? should be. Variant
> works but if possible i would like to avoid it. This would require me to
> know about the code at the invokation site. (So i'm guessing it might
> not be possible)

I have the same problem as well. I haven't figured out the best way to 
solve this yet.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list