digitalmars.D - Mission impossible
- Shachar Shemesh (12/12) Apr 11 2018 struct S {
- Basile B. (3/16) Apr 11 2018 I suppose __traits(getOverloads) doesn't work because of a bug ?
- Uknown (4/25) Apr 11 2018 The template hides any other overloads that func() has:
- Shachar Shemesh (8/32) Apr 11 2018 IF it is defined before it. If it is defined after it, it does not (but
- Uknown (4/10) Apr 11 2018 I thought there was a relevant rule about member templates, but
- Simen =?UTF-8?B?S2rDpnLDpXM=?= (5/26) Apr 11 2018 That'd be https://issues.dlang.org/show_bug.cgi?id=16206. Reorder
- Jonathan M Davis (6/29) Apr 11 2018 It looks like having the templated function makes it so that
- rikki cattermole (19/36) Apr 11 2018 import std.stdio;
- Kagamin (8/8) Apr 11 2018 If it doesn't work, hack it:
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
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
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:The template hides any other overloads that func() has: https://run.dlang.io/is/yMJXRz I'm not sure if its a bug thoughstruct 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
On 11/04/18 11:51, Uknown wrote:On Wednesday, 11 April 2018 at 08:47:12 UTC, Basile B. wrote: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.On Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh wrote:The template hides any other overloads that func() has: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 ?I'm not sure if its a bug thoughWhat else is it? Shachar
Apr 11 2018
On Wednesday, 11 April 2018 at 08:59:36 UTC, Shachar Shemesh wrote:On 11/04/18 11:51, Uknown wrote:I thought there was a relevant rule about member templates, but there isn't any such thing. My badOn Wednesday, 11 April 2018 at 08:47:12 UTC, Basile B. wrote:What else is it? ShacharOn Wednesday, 11 April 2018 at 08:36:41 UTC, Shachar Shemesh [...]
Apr 11 2018
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:That'd be https://issues.dlang.org/show_bug.cgi?id=16206. Reorder the two functions, and it works. -- Simenstruct 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
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: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 Davisstruct 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
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
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