Automatically count the number of instantiated classes in a TMP?
===

Given a template metaprogram (TMP), do C++ compilers produce build statistics that count the number of instantiated classes? Or is there any other way to automatically get this number? So for e.g. the obiquitous factorial

    #include <iostream>

    template<int N> struct fact { enum { value = N * fact<N-1>::value }; };
    template<> struct fact<1> { enum { value = 1 }; };
    
    int main()
    {
        const int x = fact<3>::value;
        std::cout << x << "\n";
        return 0;
    }

I would like to get back the number 3 (since fact<3>, fact<2>, and fact<1> are instantiated). My question is primarily for Visual C++, but answers for gcc would also be appreciated. 