From 9f0a00340d1a6a13c38b83780b5ec1a1f2d99159 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Wed, 24 Sep 2014 17:17:27 +0200 Subject: [PATCH] [AL] Add SerialExecutor::execute for two container. This is used in initialization of LocalAssemblerData for every mesh element. --- AssemblerLib/SerialExecutor.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/AssemblerLib/SerialExecutor.h b/AssemblerLib/SerialExecutor.h index 2bb5c1ac3c3..039fea7d2a7 100644 --- a/AssemblerLib/SerialExecutor.h +++ b/AssemblerLib/SerialExecutor.h @@ -40,6 +40,32 @@ struct SerialExecutor f(i, c[i], std::forward<Args_>(args)...); } + /// Same as execute(f, c), but with two containers, where the second one is + /// modified. + /// + /// \tparam F \c f type. + /// \tparam C input container type. + /// \tparam Data input/output container type. + /// + /// \param f a function that accepts a pointer to container's elements, + /// an index, and a second container element as arguments, which + /// is modified. + /// \param c a container supporting const access over operator[] and size(). + /// \param data a container supporting non-const access over operator[] and size(). + template <typename F, typename C, typename Data, typename ...Args_> + static + void +#if defined(_MSC_VER) && (_MSC_VER >= 1700) + execute(F& f, C const& c, Data& data, Args_&&... args) +#else + execute(F const& f, C const& c, Data& data, Args_&&... args) +#endif + { + assert(c.size() == data.size()); + + for (std::size_t i = 0; i < c.size(); i++) + f(i, c[i], data[i], std::forward<Args_>(args)...); + } }; } // namespace AssemblerLib -- GitLab