Thread overview
How to get the name of member function through an alias of that function
Dec 12, 2018
Peter Particle
Dec 12, 2018
Simen Kjærås
Dec 12, 2018
Peter Particle
December 12, 2018
I prefer that all the members marked with myUDA are process in the order thy appear in Foo. This happens automatically when I iterate with through 'getMemberByUDA'.

// Reduced example code
enum myUDA;
struct Foo {
public:
  @myUDA void  bar(float f) { baz = 1 / f; }
  @myUDA float bar() { return 1 / baz; }
  float baz;
}

import std.traits;
string getMemberFuncName(T)(ref T foo) {
  static foreach(member; getSymbolsByUDA!(T, myUDA)) {
    static if(isSomeFunction!member) {

      // Error: function `Test.Foo.bar(float f)` is not callable using argument types `()`
      // pragma(msg, member.stringof);

      // Don't want the fully qualified name, just the func name
      pragma(msg, fullyQualifiedName!member);

      // return the name of the first found member function
      //return name;
    }
  }
  return "";
}

void main() {
  Foo foo;
  string name = getMemberFuncName(foo);
}
December 12, 2018
On Wednesday, 12 December 2018 at 08:16:03 UTC, Peter Particle wrote:
> I prefer that all the members marked with myUDA are process in the order thy appear in Foo. This happens automatically when I iterate with through 'getMemberByUDA'.

Just replace fullyQualifiedName!member with __traits(identifier, member), and things should work.

--
  Simen
December 12, 2018
On Wednesday, 12 December 2018 at 08:36:00 UTC, Simen Kjærås wrote:
> On Wednesday, 12 December 2018 at 08:16:03 UTC, Peter Particle wrote:
>> I prefer that all the members marked with myUDA are process in the order thy appear in Foo. This happens automatically when I iterate with through 'getMemberByUDA'.
>
> Just replace fullyQualifiedName!member with __traits(identifier, member), and things should work.
>
> --
>   Simen

How could I have missed that one! THX!