Given a UDT and a constructor or a static method, I want to use __traits to access overloads of that constructor or static method.
__traits provides allMembers, which returns static and non-static functions and non-static constructors. It also provides getVirtualFunctions, which provides overloads for non-static functions. There is no equivalent to getVirtualFunctions for constructors or static functions.
Comment #1 by dhasenan — 2009-04-19T10:43:42Z
Created attachment 327
patch to add traits for dealing with static methods
Comment #2 by dhasenan — 2009-04-19T10:45:27Z
This patch adds traits:
isStaticFunction
getStaticFunctions
getOverloads
This doesn't handle constructors, but it does handle static functions.
Comment #3 by dhasenan — 2009-04-19T11:22:56Z
Created attachment 328
fixed patch
Comment #4 by dhasenan — 2009-04-19T11:25:17Z
Created attachment 329
test cases
I don't know what the preferred format is for the DMD test suite. (Hint hint.) So I did something reasonable.
Comment #5 by dhasenan — 2009-04-20T19:21:36Z
Created attachment 331
attempt 3
HA HA DISREGARD THAT, I CAN'T DIFF
(But thankfully, git can.)
Comment #6 by dhasenan — 2009-04-21T18:35:30Z
In point of fact, this does handle constructors:
__traits(getOverloads, T, "__ctor")
Comment #7 by simen.kjaras — 2018-04-20T07:19:06Z
Current DMD handles all cases in this issue, and has for a long time. getStaticFunctions is not in DMD, but can easily be implemented in a library.