From 53cd1361c503fded70b9d1636c8dc4d6e54834e0 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 21 Jan 2009 02:23:09 +0000 Subject: Made Common::Stack return refs, thus ensuring that it matches exactly the behavior of FixedStack; added unit tests svn-id: r35974 --- common/stack.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/stack.h b/common/stack.h index 238d0f6433..e20e81028d 100644 --- a/common/stack.h +++ b/common/stack.h @@ -102,7 +102,11 @@ public: void push(const T &x) { _stack.push_back(x); } - T top() const { + T &top() { + const int s = size(); + return _stack[s - 1]; + } + const T &top() const { const int s = size(); return _stack[s - 1]; } @@ -114,7 +118,10 @@ public: int size() const { return _stack.size(); } - T operator[](int i) { + T &operator[](int i) { + return _stack[i]; + } + const T &operator[](int i) const { return _stack[i]; } }; -- cgit v1.2.3