Statische Typprüfung für Metaprogrammierung von C ++ - Vorlagen

Ich konnte keine Antwort auf mein Problem finden und poste es als Frage. Ich mache ein kleines Dummy-Beispiel, um es zu erklären:

enum STORAGE_TYPE
{
    CONTIGUOUS,
    NON_CONTIGUOUS
};

template <typename T, STORAGE_TYPE type=CONTIGUOUS>
class Data
{
    public:
        void a() { return 1; }
};

// partial type specialization
template <typename T>
class Data<T, NON_CONTIGUOUS>
{
    public:
        void b() { return 0; }
};

// this method should accept any Data including specializations…
template <typename T, STORAGE_TYPE type>
void func(Data<T, type> &d)
{
    /* How could I determine statically the STORAGE_TYPE? */
    #if .. ?? 
        d.a();
    #else
        d.b();
    #endif      
}


int main()
{
    Data<int> d1;
    Data<int, NON_CONTIGUOUS> d2;

    func(d1);
    func(d2);

    return 0;
}

Bitte beachten Sie, dass (1) Ich möchte keine Spezialisierung von "func", da dies das Problem lösen könnte, aber ich möchte nur eine generische Methode "func" mit internen statischen "if" -Bedingungen zum Ausführen des Codes haben.(2) und ich würde die Lösung mit Standard-C ++ bevorzugen (nicht C ++ 0x oder Boost).

Antworten auf die Frage(2)

Ihre Antwort auf die Frage