www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Getting All Instantiations of a Template

reply dsimcha <dsimcha yahoo.com> writes:
Is there currently a way in D2 to get the parameters of all instantiations of
a template in a given scope?  For example:

class Foo {

    template instantiateMe(T) {
        void instantiateMe(T arg) {}
    }


    void foo() {
        int i;
        instantiateMe(i);
    }

    void bar() {
        float f;
        instantiateMe(f);
    }

    alias allInstantiations!instantiateMe allArgs; // (int, float)
}
Oct 24 2009
parent Walter Bright <newshound1 digitalmars.com> writes:
dsimcha wrote:
 Is there currently a way in D2 to get the parameters of all instantiations of
 a template in a given scope?

Templates are instantiated lazily, meaning it doesn't make much sense to figure this out at compile time.
Oct 24 2009