aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-05-04 15:13:15 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-05-10 11:00:45 (GMT)
commit2024f258b66ead778b7c5e048e29967cfe7e8bf2 (patch)
treeb2c1fcd3e116e6c8caa375d4fb1e0f9e556fd6a8
parent129bac1e0f0979c80902edc8e092596b81fe14f6 (diff)
downloadfluxbox-2024f258b66ead778b7c5e048e29967cfe7e8bf2.zip
fluxbox-2024f258b66ead778b7c5e048e29967cfe7e8bf2.tar.bz2
Make FbTk::MemFun[0-3] use their ResultType parameter
previously they declared the parameter, but ignored the return value of the member function. I've changed it so they pass the return value, if it is not void. MemFunSelectArg didn't have the ReturnType template parameter, so I added it for consistency. Since I was already editing the, I made all the operator()s const.
-rw-r--r--src/FbTk/MemFun.hh66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/FbTk/MemFun.hh b/src/FbTk/MemFun.hh
index a839c2e..d19bb08 100644
--- a/src/FbTk/MemFun.hh
+++ b/src/FbTk/MemFun.hh
@@ -37,8 +37,8 @@ public:
37 m_action(action) { 37 m_action(action) {
38 } 38 }
39 39
40 void operator ()() { 40 ReturnType operator ()() const {
41 (m_obj.*m_action)(); 41 return (m_obj.*m_action)();
42 } 42 }
43 43
44private: 44private:
@@ -64,8 +64,8 @@ public:
64 m_action(action) { 64 m_action(action) {
65 } 65 }
66 66
67 void operator ()(Arg1 arg1) { 67 ReturnType operator ()(Arg1 arg1) const {
68 (m_obj.*m_action)(arg1); 68 return (m_obj.*m_action)(arg1);
69 } 69 }
70 70
71private: 71private:
@@ -91,8 +91,8 @@ public:
91 m_action(action) { 91 m_action(action) {
92 } 92 }
93 93
94 void operator ()(Arg1 arg1, Arg2 arg2) { 94 ReturnType operator ()(Arg1 arg1, Arg2 arg2) const {
95 (m_obj.*m_action)(arg1, arg2); 95 return (m_obj.*m_action)(arg1, arg2);
96 } 96 }
97 97
98private: 98private:
@@ -119,8 +119,8 @@ public:
119 m_action(action) { 119 m_action(action) {
120 } 120 }
121 121
122 void operator ()(Arg1 arg1, Arg2 arg2, Arg3 arg3) { 122 ReturnType operator ()(Arg1 arg1, Arg2 arg2, Arg3 arg3) const {
123 (m_obj.*m_action)(arg1, arg2, arg3); 123 return (m_obj.*m_action)(arg1, arg2, arg3);
124 } 124 }
125 125
126private: 126private:
@@ -147,18 +147,18 @@ public:
147 } 147 }
148 148
149 template <typename IgnoreType1, typename IgnoreType2, typename IgnoreType3> 149 template <typename IgnoreType1, typename IgnoreType2, typename IgnoreType3>
150 void operator ()(IgnoreType1&, IgnoreType2&, IgnoreType3&) { 150 ReturnType operator ()(IgnoreType1&, IgnoreType2&, IgnoreType3&) const {
151 BaseType::operator ()(); 151 return BaseType::operator ()();
152 } 152 }
153 153
154 template <typename IgnoreType1, typename IgnoreType2> 154 template <typename IgnoreType1, typename IgnoreType2>
155 void operator ()(IgnoreType1&, IgnoreType2&) { 155 ReturnType operator ()(IgnoreType1&, IgnoreType2&) const {
156 BaseType::operator ()(); 156 return BaseType::operator ()();
157 } 157 }
158 158
159 template <typename IgnoreType1> 159 template <typename IgnoreType1>
160 void operator ()(IgnoreType1&) { 160 ReturnType operator ()(IgnoreType1&) const {
161 BaseType::operator ()(); 161 return BaseType::operator ()();
162 } 162 }
163}; 163};
164 164
@@ -173,13 +173,13 @@ public:
173 } 173 }
174 174
175 template <typename IgnoreType1, typename IgnoreType2> 175 template <typename IgnoreType1, typename IgnoreType2>
176 void operator ()(Arg1 arg1, IgnoreType1&, IgnoreType2&) { 176 ReturnType operator ()(Arg1 arg1, IgnoreType1&, IgnoreType2&) const {
177 BaseType::operator ()(arg1); 177 return BaseType::operator ()(arg1);
178 } 178 }
179 179
180 template <typename IgnoreType> 180 template <typename IgnoreType>
181 void operator ()(Arg1 arg1, IgnoreType&) { 181 ReturnType operator ()(Arg1 arg1, IgnoreType&) const {
182 BaseType::operator ()(arg1); 182 return BaseType::operator ()(arg1);
183 } 183 }
184}; 184};
185 185
@@ -194,8 +194,8 @@ public:
194 } 194 }
195 195
196 template < typename IgnoreType > 196 template < typename IgnoreType >
197 void operator ()(Arg1 arg1, Arg2 arg2, IgnoreType&) { 197 ReturnType operator ()(Arg1 arg1, Arg2 arg2, IgnoreType&) const {
198 BaseType::operator ()(arg1, arg2); 198 return BaseType::operator ()(arg1, arg2);
199 } 199 }
200}; 200};
201 201
@@ -224,7 +224,7 @@ MemFunIgnoreArgs( Object& obj, ReturnType (Object:: *action)(Arg1,Arg2) ) {
224 * Creates a functor that selects a specific argument of three possible ones 224 * Creates a functor that selects a specific argument of three possible ones
225 * and uses it for the single argument operator. 225 * and uses it for the single argument operator.
226 */ 226 */
227template < int ArgNum, typename Functor> 227template < int ArgNum, typename Functor, typename ReturnType>
228class MemFunSelectArgImpl { 228class MemFunSelectArgImpl {
229public: 229public:
230 230
@@ -233,18 +233,18 @@ public:
233 } 233 }
234 234
235 template <typename Type1, typename Type2, typename Type3> 235 template <typename Type1, typename Type2, typename Type3>
236 void operator ()(Type1& a, Type2& b, Type3& c) { 236 ReturnType operator ()(Type1& a, Type2& b, Type3& c) const {
237 m_func(STLUtil::SelectArg<ArgNum>()(a, b, c)); 237 return m_func(STLUtil::SelectArg<ArgNum>()(a, b, c));
238 } 238 }
239 239
240 template <typename Type1, typename Type2> 240 template <typename Type1, typename Type2>
241 void operator ()(Type1& a, Type2& b) { 241 ReturnType operator ()(Type1& a, Type2& b) const {
242 m_func(STLUtil::SelectArg<ArgNum>()(a, b)); 242 return m_func(STLUtil::SelectArg<ArgNum>()(a, b));
243 } 243 }
244 244
245 template <typename Type1> 245 template <typename Type1>
246 void operator ()(Type1& a) { 246 ReturnType operator ()(Type1& a) const {
247 m_func(a); 247 return m_func(a);
248 } 248 }
249 249
250private: 250private:
@@ -254,25 +254,25 @@ private:
254/// Creates a functor that selects the first argument of three possible ones 254/// Creates a functor that selects the first argument of three possible ones
255/// and uses it for the single argument operator. 255/// and uses it for the single argument operator.
256template <typename ReturnType, typename Object, typename Arg1> 256template <typename ReturnType, typename Object, typename Arg1>
257MemFunSelectArgImpl<0, MemFun1<ReturnType, Object, Arg1> > 257MemFunSelectArgImpl<0, MemFun1<ReturnType, Object, Arg1>, ReturnType>
258MemFunSelectArg0(Object& obj, ReturnType (Object:: *action)(Arg1)) { 258MemFunSelectArg0(Object& obj, ReturnType (Object:: *action)(Arg1)) {
259 return MemFunSelectArgImpl<0, MemFun1<ReturnType, Object, Arg1> >(MemFun(obj, action)); 259 return MemFunSelectArgImpl<0, MemFun1<ReturnType, Object, Arg1>, ReturnType>(MemFun(obj, action));
260} 260}
261 261
262/// Creates a functor that selects the second argument (or first if there is 262/// Creates a functor that selects the second argument (or first if there is
263/// only one) of three possible onesand uses it for the single argument operator. 263/// only one) of three possible onesand uses it for the single argument operator.
264template <typename ReturnType, typename Object, typename Arg1> 264template <typename ReturnType, typename Object, typename Arg1>
265MemFunSelectArgImpl<1, MemFun1<ReturnType, Object, Arg1> > 265MemFunSelectArgImpl<1, MemFun1<ReturnType, Object, Arg1>, ReturnType>
266MemFunSelectArg1(Object& obj, ReturnType (Object:: *action)(Arg1)) { 266MemFunSelectArg1(Object& obj, ReturnType (Object:: *action)(Arg1)) {
267 return MemFunSelectArgImpl<1, MemFun1<ReturnType, Object, Arg1> >(MemFun(obj, action)); 267 return MemFunSelectArgImpl<1, MemFun1<ReturnType, Object, Arg1>, ReturnType>(MemFun(obj, action));
268} 268}
269 269
270/// Creates a functor that selects the third argument (or the last argument if there is 270/// Creates a functor that selects the third argument (or the last argument if there is
271/// less than three arguments) of three possible onesand uses it for the single argument operator. 271/// less than three arguments) of three possible onesand uses it for the single argument operator.
272template <typename ReturnType, typename Object, typename Arg1> 272template <typename ReturnType, typename Object, typename Arg1>
273MemFunSelectArgImpl<2, MemFun1<ReturnType, Object, Arg1> > 273MemFunSelectArgImpl<2, MemFun1<ReturnType, Object, Arg1>, ReturnType>
274MemFunSelectArg2(Object& obj, ReturnType (Object:: *action)(Arg1)) { 274MemFunSelectArg2(Object& obj, ReturnType (Object:: *action)(Arg1)) {
275 return MemFunSelectArgImpl<2, MemFun1<ReturnType, Object, Arg1> >(MemFun(obj, action)); 275 return MemFunSelectArgImpl<2, MemFun1<ReturnType, Object, Arg1>, ReturnType>(MemFun(obj, action));
276} 276}
277 277
278} // namespace FbTk 278} // namespace FbTk