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 20:13:12 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:43:13 +0300
commit44c86c6e572a7308430d5c49da13a94bda2042fc (patch)
treecd042a2f90c95686daabce5395cc42e1de57f9ec /base
parente874d2adbf248115a62b28427fcfbe39c96ceea9 (diff)
Make range delete scope guard more generic.
Diffstat (limited to 'base')
-rw-r--r--base/stl_add.hpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/base/stl_add.hpp b/base/stl_add.hpp
index d85a94b63a..c118e6773f 100644
--- a/base/stl_add.hpp
+++ b/base/stl_add.hpp
@@ -111,17 +111,33 @@ struct DeleteFunctor
}
};
-template <class TContainer> class DeleteRangeGuard
+namespace impl
{
- TContainer & m_cont;
-public:
- DeleteRangeGuard(TContainer & cont) : m_cont(cont) {}
- ~DeleteRangeGuard()
+ template <class TContainer, class TDeletor> class DeleteRangeFunctor
{
- for_each(m_cont.begin(), m_cont.end(), DeleteFunctor());
- m_cont.clear();
- }
-};
+ TContainer & m_cont;
+ TDeletor m_deletor;
+
+ public:
+ DeleteRangeFunctor(TContainer & cont, TDeletor const & deletor)
+ : m_cont(cont), m_deletor(deletor)
+ {
+ }
+
+ void operator() ()
+ {
+ for_each(m_cont.begin(), m_cont.end(), m_deletor);
+ m_cont.clear();
+ }
+ };
+}
+
+template <class TContainer, class TDeletor>
+impl::DeleteRangeFunctor<TContainer, TDeletor>
+GetRangeDeletor(TContainer & cont, TDeletor const & deletor)
+{
+ return impl::DeleteRangeFunctor<TContainer, TDeletor>(cont, deletor);
+}
struct NoopFunctor
{