I am reasonably new to C++ and have limited experience of templates. At the moment I am trying to implement a concurrent queue based on the example provided here. I am having problems compiling it and keep getting an error stating that "ISO C++ forbids declaration of ‘queue’ with no type" even after I stripped down the code to the following simple example:
template<typename Data> class concurrent_queue {
private:
std::queue<Data> the_queue;
public:
void push(Data const& data) {
the_queue.push(data);
}
bool empty() const {
return the_queue.empty();
}
void pop(Data& popped_value) {
popped_value=the_queue.front();
the_queue.pop();
}
};
int main(int argc, char** argv) {
concurrent_queue<std::string> Q;
// Simple test code will go here
}
I am a bit puzzled by this since I have provided the type 'Data' for the queue. Can someone please help me point out what I have done wrong?