SigUtil  0.95
Utility modules for modern C++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
for_each.hpp
Go to the documentation of this file.
1 /*
2 Copyright© 2014 Akihiro Nishimura
3 
4 This software is released under the MIT License.
5 http://opensource.org/licenses/mit-license.php
6 */
7 
8 #ifndef SIG_UTIL_FOREACH_HPP
9 #define SIG_UTIL_FOREACH_HPP
10 
11 #include "../helper/helper_modules.hpp"
12 #include "../helper/container_helper.hpp"
13 
14 
16 
17 namespace sig
18 {
20 
45 template <class F, class... Cs>
46 void for_each(F&& func, Cs&&... containers)
47 {
48  const uint length = min(containers.size()...);
49  iterative_assign(length, std::forward<F>(func), impl::begin(std::forward<Cs>(containers))...);
50 }
51 
53 
77 template <class F, class... Cs>
78 void for_each(F&& func, int init, Cs&&... containers)
79 {
80  const uint length = min(containers.size()...);
81  iterative_assign(length, init, std::forward<F>(func), impl::begin(std::forward<Cs>(containers))...);
82 }
83 
84 }
85 #endif
void for_each(F &&func, Cs &&...containers)
複数コンテナを反復処理
Definition: for_each.hpp:46
void iterative_assign(uint loop, F &&func, Its...iterators)
auto min(T v) -> T
Definition: array.hpp:15
auto begin(C &&c) -> std::move_iterator< typename RC::iterator >