Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-09-07 19:19:11 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:43:12 +0300
commit3d3bfb13659f92f006a4d3b4e300997273744ee4 (patch)
treea22e12c5ce89c78f204871e6c0cb8656e9cc4932 /base
parent2cf9d90c221e6ecf97cac3c6a56bd4e072f0474b (diff)
Add guard for deleting objects in container.
Diffstat (limited to 'base')
-rw-r--r--base/stl_add.hpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/base/stl_add.hpp b/base/stl_add.hpp
index 0a905fa190..d85a94b63a 100644
--- a/base/stl_add.hpp
+++ b/base/stl_add.hpp
@@ -111,9 +111,21 @@ struct DeleteFunctor
}
};
+template <class TContainer> class DeleteRangeGuard
+{
+ TContainer & m_cont;
+public:
+ DeleteRangeGuard(TContainer & cont) : m_cont(cont) {}
+ ~DeleteRangeGuard()
+ {
+ for_each(m_cont.begin(), m_cont.end(), DeleteFunctor());
+ m_cont.clear();
+ }
+};
+
struct NoopFunctor
{
- template <typename T> inline void operator () (T const &) const
+ template <typename T> void operator () (T const &) const
{
}
};