Why does C++ standard queue have back function when stack doesn't have bottom function?
c++, queue, stack, std
Solution
There might be other reasons for `back()`, but you needed it for a queue because of the idiom from C++03 of cheaply copying an "empty" object into a container and then `swap`ping that new element with a "full" object that would be very expensive to copy. This reason is more or less obsolete in C++11 thanks to move semantics, but of course `back()` is still needed for compatibility.
You don't need `bottom()` for a stack for that (or any other) reason.
Problem
On one of many unofficial C++ reference websites, there are listed member functions `front()` and `back()` for `std::queue`. However, `std::stack` only has `top()` function. It makes sense for the stack to not have a `bottom()` function because that's the definition of a stack. What I don't get is why did the C++ standard committee chose not to follow the definition of a queue and provide with `back()` function for queue and chose to follow the definition of a stack and not provide with `bottom()` function.