Skip to content
Snippets Groups Projects
Commit 9196695b authored by Christian Engwer's avatar Christian Engwer
Browse files

fix FS#621

* implement rangecheck for finite stack (disabled when compiling with NDEBUG)
* fix lru with _GLIBCXX_DEBUG

[[Imported from SVN: r5753]]
parent e575b6ff
No related branches found
No related tags found
No related merge requests found
......@@ -45,18 +45,33 @@ namespace Dune {
//! Puts a new object onto the stack
void push (const T& t)
{
#ifndef NDEBUG
if (full())
DUNE_THROW(Dune::RangeError,
"trying to call push on a full FiniteStack");
#endif
s[f++] = t;
}
//! Removes and returns the uppermost object from the stack
T pop ()
{
#ifndef NDEBUG
if (empty())
DUNE_THROW(Dune::RangeError,
"trying to call top on an empty FiniteStack");
#endif
return s[--f];
}
//! Returns the uppermost object on the stack
T top () const
{
#ifndef NDEBUG
if (empty())
DUNE_THROW(Dune::RangeError,
"trying to call pop on an empty FiniteStack");
#endif
return s[f-1];
}
......
......@@ -158,7 +158,7 @@ namespace Dune {
/* insert item as mru */
iterator it = _data.insert(_data.begin(), x);
/* store index */
_index[key] = it;
_index.insert(std::make_pair(key,it));
return it->second;
}
......
......@@ -47,6 +47,7 @@ int main () {
stack1.pop();
// exception has to happen
// make sure you compile this test without NDEBUG
std::cerr << "Expected exception Dune::RangeError, but nothing caught\n";
return 1;
} catch (Dune::RangeError &e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment