From 34a9c8304a03ecdb9cc9b1d5adb6c56e3de2d4f2 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 20 May 2014 10:15:28 -0700 Subject: [PATCH] feat(kernel/environment): add for_each method for traversing environment declarations Signed-off-by: Leonardo de Moura --- src/kernel/environment.cpp | 4 ++++ src/kernel/environment.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index c2c336189..485b8b696 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -167,4 +167,8 @@ environment environment::update(unsigned id, std::shared_ptr const & f) const { + m_definitions.for_each([&](name const &, definition const & d) { return f(d); }); +} } diff --git a/src/kernel/environment.h b/src/kernel/environment.h index 42e7fe852..8d3c290fd 100644 --- a/src/kernel/environment.h +++ b/src/kernel/environment.h @@ -196,6 +196,9 @@ public: is not pointer equal to the result. */ environment forget() const; + + /** \brief Apply the function \c f to each definition */ + void for_each(std::function const & f) const; }; class name_generator;