Panagiotis Filianos Panagiotis Filianos - 16 days ago 5
C++ Question

Bitset inside template declaration

I would like to know if it is possible to have bitset inside a template declaration like so:

ListData<bitset<64>>* hamming = new ListData<bitset<64>>();


ListData is class containing a T element like so:

template <typename T>
class ListData {
public:
...
private:
T number;
};


The compiler says that the template argument invalid and that hamming was not declared in this scope.
Any idea?

p.s. I am unable to use C++ vector containers due to my assignment's restrictions

Answer

I found the answer. It turns out the compiler thought ">>" in:

ListData<bitset<64>>* hamming = new ListData<bitset<64>>();

was recognised as the overloaded operator >>.

ListData<bitset<64> >* hammingList = new ListData<bitset<64> >();

Thus the above fixes the problem.