On 03/24/2012 09:07 PM, Philippe Sigaud wrote:
On Sat, Mar 24, 2012 at 18:07, Artur Skawina<art.08...@gmail.com> wrote:
foreach (f; __traits(getOverloads, __traits(parent, main), "foo")) {
Hey, this
^^^^^^^^^^^^^^^^^^^^^^
it's a way to get the current module, right? Nice trick, I didn't think of this.
Its limitation is it won't work outside the 'main() {}' module.
You can get the parent of an alias. The following template finds all
overloads of a given symbol:
template ID(T...){alias T ID;}
template getOverloads(alias f){
enum fname = f.stringof[0..f.stringof.indexOf("(")];
alias ID!(__traits(getOverloads, __traits(parent, f), fname))
getOverloads;
}
I think this should go into std.traits, as soon as it works. (DMD is
buggy when it comes to taking the .stringof of a function. It
misinterprets it as a property function call in some cases but not in
others. Messy.)