I think that I don't quite understand combining templating with derived classes. I suspect I am not using typename where I am supposed to.
With the following class that I've made:
template <typename T>
struct NumericStruct
{
public:
NumericStruct():
value(0),
index(0) {}
T value
unsigned int index;
};
template <typename T, template <typename, typename = std::allocator<NumericStruct<T> > > class Container>
class SuperBuffer
{
public:
enum Category
{
THIS = 0,
THAT
};
SuperBuffer(const Category cat):
category(cat),
buffer() {}
void push_back( T number, unsigned int index );
T calculate() const;
protected:
Category category;
Container<NumericStruct<T> > buffer;
};
When I make a derived class such as the following, it compiles okay.
//THIS IS OKAY
class SuperCircularBuffer : public SuperBuffer<double, boost::circular_buffer>
{
public:
SuperCircularBuffer(SuperBuffer<double, boost::circular_buffer>::Category type = SuperBuffer<double, boost::circular_buffer>::THIS):
SuperBuffer<double, boost::circular_buffer>(type)
{};
bool full() const
{
return buffer.full();
}
};
However, when I do the following, it doesn't compile:
//COMPILER COMPLAINS ABOUT THIS
template <typename T = double>
class SuperCircularBuffer : public SuperBuffer<T, boost::circular_buffer>
{
public:
SuperCircularBuffer(SuperBuffer<T, boost::circular_buffer>::Category type = SuperBuffer<T, boost::circular_buffer>::THIS):
SuperBuffer<T, boost::circular_buffer>(type)
{};
bool full() const
{
return buffer.full();
}
};
I've been trying different things but at this point I think I am just guessing. Any help would be appreciated!