Re: Mission impossible

2018-04-11 Thread Kagamin via Digitalmars-d

If it doesn't work, hack it:

struct S {
static void func(T)(uint a, T t) {
}

static void func1() {
}

alias func=func1;
}


Re: Mission impossible

2018-04-11 Thread Uknown via Digitalmars-d
On Wednesday, 11 April 2018 at 08:59:36 UTC, Shachar Shemesh 
wrote:

On 11/04/18 11:51, Uknown wrote:

On Wednesday, 11 April 2018 at 08:47:12 UTC, Basile B. wrote:
On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh 
[...]

What else is it?

Shachar


I thought there was a relevant rule about member templates, but 
there isn't any such thing. My bad


Re: Mission impossible

2018-04-11 Thread rikki cattermole via Digitalmars-d

On 11/04/2018 8:36 PM, Shachar Shemesh wrote:

struct S {
     static void func(T)(uint a, T t) {
     }

     static void func() {
     }
}

Your mission, Jim, should you choose to accept it, is this:

Get a pointer to the version of the function that accepts no arguments.

As always, should you or any of your Force be caught or killed, the 
Secretary will disavow any knowledge of your actions. This disc will 
self-destruct in ten seconds.


Good luck, Jim.


import std.stdio;
void main()
{
writeln("Hello D ", !(S, "func"));
wrapper!(S, "func");
}

struct S {
static void func(T)(uint a, T t) {
writeln("a");
}

static void func() {
writeln("b");
}
}

pragma(inline, true)
auto wrapper(T, string name, Args...)(Args args) {
mixin("return T." ~ name ~ "(args);");
}


Re: Mission impossible

2018-04-11 Thread Shachar Shemesh via Digitalmars-d

On 11/04/18 11:51, Uknown wrote:

On Wednesday, 11 April 2018 at 08:47:12 UTC, Basile B. wrote:

On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh wrote:

struct S {
    static void func(T)(uint a, T t) {
    }

    static void func() {
    }
}

Your mission, Jim, should you choose to accept it, is this:

Get a pointer to the version of the function that accepts no arguments.

As always, should you or any of your Force be caught or killed, the 
Secretary will disavow any knowledge of your actions. This disc will 
self-destruct in ten seconds.


Good luck, Jim.


I suppose __traits(getOverloads) doesn't work because of a bug ?


The template hides any other overloads that func() has:


IF it is defined before it. If it is defined after it, it does not (but 
it is then possible that the non-template version hides the template one).


The problem is that S has two members called "func". One is a function, 
and the other is a template. "getOverloads" is not built to distinguish 
between the two.



I'm not sure if its a bug though


What else is it?

Shachar


Re: Mission impossible

2018-04-11 Thread Uknown via Digitalmars-d

On Wednesday, 11 April 2018 at 08:47:12 UTC, Basile B. wrote:
On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh 
wrote:

struct S {
static void func(T)(uint a, T t) {
}

static void func() {
}
}

Your mission, Jim, should you choose to accept it, is this:

Get a pointer to the version of the function that accepts no 
arguments.


As always, should you or any of your Force be caught or 
killed, the Secretary will disavow any knowledge of your 
actions. This disc will self-destruct in ten seconds.


Good luck, Jim.


I suppose __traits(getOverloads) doesn't work because of a bug ?


The template hides any other overloads that func() has:

https://run.dlang.io/is/yMJXRz

I'm not sure if its a bug though


Re: Mission impossible

2018-04-11 Thread Simen Kjærås via Digitalmars-d

On Wednesday, 11 April 2018 at 08:47:12 UTC, Basile B. wrote:
On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh 
wrote:

struct S {
static void func(T)(uint a, T t) {
}

static void func() {
}
}

Your mission, Jim, should you choose to accept it, is this:

Get a pointer to the version of the function that accepts no 
arguments.


As always, should you or any of your Force be caught or 
killed, the Secretary will disavow any knowledge of your 
actions. This disc will self-destruct in ten seconds.


Good luck, Jim.


I suppose __traits(getOverloads) doesn't work because of a bug ?


That'd be https://issues.dlang.org/show_bug.cgi?id=16206. Reorder 
the two functions, and it works.


--
  Simen


Re: Mission impossible

2018-04-11 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, April 11, 2018 08:47:12 Basile B. via Digitalmars-d wrote:
> On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh
>
> wrote:
> > struct S {
> >
> > static void func(T)(uint a, T t) {
> > }
> >
> > static void func() {
> > }
> >
> > }
> >
> > Your mission, Jim, should you choose to accept it, is this:
> >
> > Get a pointer to the version of the function that accepts no
> > arguments.
> >
> > As always, should you or any of your Force be caught or killed,
> > the Secretary will disavow any knowledge of your actions. This
> > disc will self-destruct in ten seconds.
> >
> > Good luck, Jim.
>
> I suppose __traits(getOverloads) doesn't work because of a bug ?

It looks like having the templated function makes it so that
__traits(getOverloads, ...) gives an empty AliasSeq. It's probably something
that got missed when it was made possible to overload templated functions
with non-templated functions.

- Jonathan M Davis



Re: Mission impossible

2018-04-11 Thread Basile B. via Digitalmars-d
On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh 
wrote:

struct S {
static void func(T)(uint a, T t) {
}

static void func() {
}
}

Your mission, Jim, should you choose to accept it, is this:

Get a pointer to the version of the function that accepts no 
arguments.


As always, should you or any of your Force be caught or killed, 
the Secretary will disavow any knowledge of your actions. This 
disc will self-destruct in ten seconds.


Good luck, Jim.


I suppose __traits(getOverloads) doesn't work because of a bug ?


Mission impossible

2018-04-11 Thread Shachar Shemesh via Digitalmars-d

struct S {
static void func(T)(uint a, T t) {
}

static void func() {
}
}

Your mission, Jim, should you choose to accept it, is this:

Get a pointer to the version of the function that accepts no arguments.

As always, should you or any of your Force be caught or killed, the 
Secretary will disavow any knowledge of your actions. This disc will 
self-destruct in ten seconds.


Good luck, Jim.