Injecting a circular buffer in C ++ using deque

I am trying to implement a circular buffer for assignment. To save time, I want to use deque inside my reordering buffer class. Here is my first attempt to write a class containing deque.

#ifndef ROB_H_
#define ROB_H_

#include <deque>
#include <cstdio>

using namespace std;

class ReorderBuffer{
    public:
        ReorderBuffer (int size);
        void doStuff();

        std::deque<int> buffer;
};    

ReorderBuffer::ReorderBuffer (int size){
    std::deque<int> buffer(size);
}

void ReorderBuffer::doStuff(){

    std::deque<int> buffer(4);

    buffer.push_back(5);
    buffer.push_front(2);
    buffer.push_back(3);
    buffer.push_back(4);
    printf("%d %d\n",buffer.at(0),buffer.pop_front());

}


#endif

Basically I create a reorder buffer with size 4 and call doStuff (). When I try to compile, it talks about the invalid use of the void expression. I narrowed the error down to my call to buffer.pop_front (). Why is he complaining and what is the best way to put a deque in my class? Thanks!

+4
source share
1 answer

std::deque::pop_front void. . at() , pop_front pop_back, , , .

http://en.cppreference.com/w/cpp/container/deque/pop_front

+4

All Articles