Substitute [] by std::array

Viewed 132

Is there a way to substitute VECTOR_TYPE::*memberlist[sizeof...(SCALAR)] by std::array< ??? >?

struct myVec
{
    double x;
    double y;
};

template < typename VECTOR_TYPE, typename SCALAR_TYPE, SCALAR_TYPE VECTOR_TYPE::*...SCALAR >
struct vector_template : VECTOR_TYPE
{
    SCALAR_TYPE & operator[]( size_t inx )
    {
        constexpr SCALAR_TYPE VECTOR_TYPE::*memberlist[sizeof...(SCALAR)]{ SCALAR... };
        return this->*(memberlist[inx]);
    }
};

int main()
{
    vector_template < myVec, double, &myVec::x, &myVec::y > vec;

    vec[0] = 0.0;
    vec[1] = 0.0;

    return 0;
}
1 Answers
Related