I have a template class with lots of functions and only want to specialize a few of them, while also adding a member variable.
Is that possible without the need to reimplement all the functions for the specialized class?
What I have:
template<class T> class Vector3
{
    union {
        T data[3];
        struct { T x, y, z; };
    };
    //a lot of functions
    T Length() { ... };
};
What I want to do:
template<> class Vector3<float>
{
    union {
        float data[3];
        struct { float x, y, z; };
        //new union member only for <float>!
        __m128 xmm;
    };
    float Length() {
        //special instructions for special case <float>
    };
};
As 95% of all functions stay exactly the same, I definitely don't want to reimplement them for every single specialization. How can I achieve that?
Aucun commentaire:
Enregistrer un commentaire