smarter reflection issue

Lloyd Dupont ld-REMOVE at galador.net
Fri Jun 17 19:54:01 PDT 2011


It helped! it's working now! :)
Thanks!

"Jesse Phillips"  wrote in message news:itgg6i$2tf3$1 at digitalmars.com...

Lloyd Dupont Wrote:

> Hi Jesse, this won't work!
> It's my fault in not explaining my problem well though...
>
> I forget to mention something...
> I'm using property syntax and try to call the method
>
> Say I have
> =====
> private int _foo;
> @property public int Foo() { return _foo; }
> @property public void Foo(int value) { _foo = value; }
> =====
> if I call MEMBER(MyClass, "Foo")
> I'd like to do some static test for "int Foo()" and "void Foo(int)"
>
> So... how will I go on solving that?

I don't remember how to package these up nicely:

void MEMBER(T, string fun)(T m) if(expectedType!(T, fun).valid) {
}

template expectedType(T, string fun) {
private T s;
static if(mixin("__traits(compiles, s."~fun~" = 0) && is(typeof(s."~fun~") : 
int)"))
enum valid = true;
else
enum valid = false;
} 



More information about the Digitalmars-d-learn mailing list