I am using the queue library from C++ and I need to pick the front element from the queue and edit this element without removing it from the queue. There is any way to do this? I need to do something like this:
queue<int> myQueue;
myQueue.push(1);
myQueue.push(2);
cout << myQueue.front(); // 2
int a = myQueue.front();
a = 3;
cout << myQueue.front(); // 3
Obviously this don't work =D. Anyone knows how to do it?
front() returns a reference,
int &a = queue.front();
a = 3;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With