www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Mission impossible

reply Shachar Shemesh <shachar weka.io> writes:
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.
Apr 11 2018
next sibling parent reply Basile B. <b2.temp gmx.com> writes:
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 ?
Apr 11 2018
next sibling parent reply Uknown <sireeshkodali1 gmail.com> writes:
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
Apr 11 2018
parent reply Shachar Shemesh <shachar weka.io> writes:
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
Apr 11 2018
parent Uknown <sireeshkodali1 gmail.com> writes:
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
Apr 11 2018
prev sibling next sibling parent Simen =?UTF-8?B?S2rDpnLDpXM=?= <simen.kjaras gmail.com> writes:
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
Apr 11 2018
prev sibling parent Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
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
Apr 11 2018
prev sibling next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
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 ", &wrapper!(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);"); }
Apr 11 2018
prev sibling parent Kagamin <spam here.lot> writes:
If it doesn't work, hack it:

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

     static void func1() {
     }

     alias func=func1;
}
Apr 11 2018