SigUtil  0.95
Utility modules for modern C++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
assign_operation.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_ASSIGN_OPERATION_HPP
9 #define SIG_UTIL_ASSIGN_OPERATION_HPP
10 
11 #include "../helper/helper_modules.hpp"
12 #include "../helper/container_helper.hpp"
13 #include "../calculation/for_each.hpp"
14 
16 
17 namespace sig
18 {
20 
36 template <class F, class C1, class C2,
37  typename std::enable_if<impl::container_traits<C1>::exist && impl::container_traits<C2>::exist>::type*& = enabler
38 >
40  F&& assign_op,
41  C1& dest,
42  C2 const& src)
43 {
44  sig::for_each(std::forward<F>(assign_op), dest, src);
45 }
46 
48 
63 template <class F, class C, class T,
64  typename std::enable_if<impl::container_traits<C>::exist && !impl::container_traits<T>::exist>::type*& = enabler
65 >
67  F&& assign_op,
68  C& dest,
69  T src)
70 {
71  for (auto& e : dest){
72  std::forward<F>(assign_op)(e, src);
73  }
74 }
75 
76 
78 
82 {
83  template <class T1, class T2>
84  void operator()(T1& v1, T2&& v2) const
85  {
86  v1 += std::forward<T2>(v2);
87  }
88 };
89 
91 
95 {
96  template <class T1, class T2>
97  void operator()(T1& v1, T2&& v2) const
98  {
99  v1 -= std::forward<T2>(v2);
100  }
101 };
102 
104 
108 {
109  template <class T1, class T2>
110  void operator()(T1& v1, T2&& v2) const
111  {
112  v1 *= std::forward<T2>(v2);
113  }
114 };
115 
117 
121 {
122  template <class T1, class T2>
123  void operator()(T1& v1, T2&& v2) const
124  {
125  v1 /= std::forward<T2>(v2);
126  }
127 };
128 
129 }
130 #endif
void for_each(F &&func, Cs &&...containers)
複数コンテナを反復処理
Definition: for_each.hpp:46
void * enabler
void operator()(T1 &v1, T2 &&v2) const
compound_assignment の第1引数に指定する代入関数のプリセット(乗算代入)
void operator()(T1 &v1, T2 &&v2) const
void compound_assignment(F &&assign_op, C1 &dest, C2 const &src)
コンテナへの代入演算 (element-wise: container and container)
void operator()(T1 &v1, T2 &&v2) const
void operator()(T1 &v1, T2 &&v2) const
compound_assignment の第1引数に指定する代入関数のプリセット(加算代入)
compound_assignment の第1引数に指定する代入関数のプリセット(除算代入)
Definition: array.hpp:15
compound_assignment の第1引数に指定する代入関数のプリセット(減算代入)