If I do not to want to create a new container in order to do so?
Try this:
template
struct myStack : std::stack {
typedef std::stack Stack;
using Stack::stack;
using Stack::c;
};
int main()
{
myStack> s;
s.push(1);
s.push(2);
std::deque::iterator it = s.c.begin();
while (it != s.c.end())
std::cout << ' ' << *it++;
}
Here we expose underlying container of std::stack as member c.