vendredi 28 avril 2017

data member access in template programming

I am creating a template class with specialized behavior for two different sizes, and general behavior in general class as below::

template<typename T, size_t DIM>
class Dataset
{
public:
    // all the constructors are defaulted
    // all the general behavior implementation

    std::vector<T> _data;
};

Given the flow of data for the class below, I am expecting to have access to _data vector, right ?!

template<typename T>
class Dataset<T, 1>
{
public:
    T & operator()(const size_t & index)
    {
        return _data[index];
    }
};

however, I get the compilation error of _data couldn't be resolved. What is the problem here ?!! Thanks

Aucun commentaire:

Enregistrer un commentaire