you are right, std::stack is safer.