Thread overview | |||||
---|---|---|---|---|---|
|
February 04, 2021 How to tell between int[] and int[]... with introspection? | ||||
---|---|---|---|---|
| ||||
Given these functions:
int func1(string x, int[] y);
int func2(string x, int[] y...);
Is there a way to tell, using compile-time introspection, the difference between their signatures?
Using std.traits.Parameters shows both functions as having signature
(string, int[]).
typeof(&func2).stringof does show the `...` but I'd rather not rely on parsing .stringof if at all possible.
T
--
Which is worse: ignorance or apathy? Who knows? Who cares? -- Erich Schubert
|
February 04, 2021 Re: How to tell between int[] and int[]... with introspection? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Thursday, 4 February 2021 at 17:18:27 UTC, H. S. Teoh wrote: > Given these functions: > > int func1(string x, int[] y); > int func2(string x, int[] y...); > > Is there a way to tell, using compile-time introspection, the difference between their signatures? > > Using std.traits.Parameters shows both functions as having signature > (string, int[]). > > typeof(&func2).stringof does show the `...` but I'd rather not rely on parsing .stringof if at all possible. > > > T Maybe this? https://dlang.org/phobos/std_traits.html#variadicFunctionStyle |
February 04, 2021 Re: How to tell between int[] and int[]... with introspection? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Jones | On Thursday, 4 February 2021 at 17:21:52 UTC, Ben Jones wrote: > On Thursday, 4 February 2021 at 17:18:27 UTC, H. S. Teoh wrote: >> Given these functions: >> >> int func1(string x, int[] y); >> int func2(string x, int[] y...); >> >> Is there a way to tell, using compile-time introspection, the difference between their signatures? >> >> Using std.traits.Parameters shows both functions as having signature >> (string, int[]). >> >> typeof(&func2).stringof does show the `...` but I'd rather not rely on parsing .stringof if at all possible. >> >> >> T > > Maybe this? https://dlang.org/phobos/std_traits.html#variadicFunctionStyle https://run.dlang.io/is/mcnPp9 |
Copyright © 1999-2021 by the D Language Foundation