I went through this page but I am not able to get the reason for the same . There it is mentioned that
"it is more sensible for it to return no value at all and to require clients to use front() to inspect the value at the front of the queue"
But inspecting an element from front() also required that element to be copied in lvalue. For example in this code segment
std::queue<int> myqueue;
int myint;
int result;
std::cin >> myint;
myqueue.push (myint);
/* here temporary will be created on RHS which will be assigned to
result, and in case if returns by reference then result will be
rendered invalid after pop operation */
result = myqueue.front(); //result.
std::cout << ' ' << result;
myqueue.pop();
on fifth line cout object first creates a copy of myqueue.front() then assigns that to result. So, whats the difference, pop function could have done the same thing.
void std::queue::pop();).front()also required that element to be copied in lvalue" - no it doesn't.frontreturns a reference, not a value. You can inspect the value it refers to without copying it.pop(). If you usestd::queue<T, std::list<T>>then there is no concern about the reference provided fromfront()being invalidated by apush(). But you must know your usage pattern and should document your constraints.