From 2024f258b66ead778b7c5e048e29967cfe7e8bf2 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 4 May 2011 17:13:15 +0200 Subject: 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. --- src/FbTk/MemFun.hh | 66 +++++++++++++++++++++++++++--------------------------- 1 file 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: m_action(action) { } - void operator ()() { - (m_obj.*m_action)(); + ReturnType operator ()() const { + return (m_obj.*m_action)(); } private: @@ -64,8 +64,8 @@ public: m_action(action) { } - void operator ()(Arg1 arg1) { - (m_obj.*m_action)(arg1); + ReturnType operator ()(Arg1 arg1) const { + return (m_obj.*m_action)(arg1); } private: @@ -91,8 +91,8 @@ public: m_action(action) { } - void operator ()(Arg1 arg1, Arg2 arg2) { - (m_obj.*m_action)(arg1, arg2); + ReturnType operator ()(Arg1 arg1, Arg2 arg2) const { + return (m_obj.*m_action)(arg1, arg2); } private: @@ -119,8 +119,8 @@ public: m_action(action) { } - void operator ()(Arg1 arg1, Arg2 arg2, Arg3 arg3) { - (m_obj.*m_action)(arg1, arg2, arg3); + ReturnType operator ()(Arg1 arg1, Arg2 arg2, Arg3 arg3) const { + return (m_obj.*m_action)(arg1, arg2, arg3); } private: @@ -147,18 +147,18 @@ public: } template - void operator ()(IgnoreType1&, IgnoreType2&, IgnoreType3&) { - BaseType::operator ()(); + ReturnType operator ()(IgnoreType1&, IgnoreType2&, IgnoreType3&) const { + return BaseType::operator ()(); } template - void operator ()(IgnoreType1&, IgnoreType2&) { - BaseType::operator ()(); + ReturnType operator ()(IgnoreType1&, IgnoreType2&) const { + return BaseType::operator ()(); } template - void operator ()(IgnoreType1&) { - BaseType::operator ()(); + ReturnType operator ()(IgnoreType1&) const { + return BaseType::operator ()(); } }; @@ -173,13 +173,13 @@ public: } template - void operator ()(Arg1 arg1, IgnoreType1&, IgnoreType2&) { - BaseType::operator ()(arg1); + ReturnType operator ()(Arg1 arg1, IgnoreType1&, IgnoreType2&) const { + return BaseType::operator ()(arg1); } template - void operator ()(Arg1 arg1, IgnoreType&) { - BaseType::operator ()(arg1); + ReturnType operator ()(Arg1 arg1, IgnoreType&) const { + return BaseType::operator ()(arg1); } }; @@ -194,8 +194,8 @@ public: } template < typename IgnoreType > - void operator ()(Arg1 arg1, Arg2 arg2, IgnoreType&) { - BaseType::operator ()(arg1, arg2); + ReturnType operator ()(Arg1 arg1, Arg2 arg2, IgnoreType&) const { + return BaseType::operator ()(arg1, arg2); } }; @@ -224,7 +224,7 @@ MemFunIgnoreArgs( Object& obj, ReturnType (Object:: *action)(Arg1,Arg2) ) { * Creates a functor that selects a specific argument of three possible ones * and uses it for the single argument operator. */ -template < int ArgNum, typename Functor> +template < int ArgNum, typename Functor, typename ReturnType> class MemFunSelectArgImpl { public: @@ -233,18 +233,18 @@ public: } template - void operator ()(Type1& a, Type2& b, Type3& c) { - m_func(STLUtil::SelectArg()(a, b, c)); + ReturnType operator ()(Type1& a, Type2& b, Type3& c) const { + return m_func(STLUtil::SelectArg()(a, b, c)); } template - void operator ()(Type1& a, Type2& b) { - m_func(STLUtil::SelectArg()(a, b)); + ReturnType operator ()(Type1& a, Type2& b) const { + return m_func(STLUtil::SelectArg()(a, b)); } template - void operator ()(Type1& a) { - m_func(a); + ReturnType operator ()(Type1& a) const { + return m_func(a); } private: @@ -254,25 +254,25 @@ private: /// Creates a functor that selects the first argument of three possible ones /// and uses it for the single argument operator. template -MemFunSelectArgImpl<0, MemFun1 > +MemFunSelectArgImpl<0, MemFun1, ReturnType> MemFunSelectArg0(Object& obj, ReturnType (Object:: *action)(Arg1)) { - return MemFunSelectArgImpl<0, MemFun1 >(MemFun(obj, action)); + return MemFunSelectArgImpl<0, MemFun1, ReturnType>(MemFun(obj, action)); } /// Creates a functor that selects the second argument (or first if there is /// only one) of three possible onesand uses it for the single argument operator. template -MemFunSelectArgImpl<1, MemFun1 > +MemFunSelectArgImpl<1, MemFun1, ReturnType> MemFunSelectArg1(Object& obj, ReturnType (Object:: *action)(Arg1)) { - return MemFunSelectArgImpl<1, MemFun1 >(MemFun(obj, action)); + return MemFunSelectArgImpl<1, MemFun1, ReturnType>(MemFun(obj, action)); } /// Creates a functor that selects the third argument (or the last argument if there is /// less than three arguments) of three possible onesand uses it for the single argument operator. template -MemFunSelectArgImpl<2, MemFun1 > +MemFunSelectArgImpl<2, MemFun1, ReturnType> MemFunSelectArg2(Object& obj, ReturnType (Object:: *action)(Arg1)) { - return MemFunSelectArgImpl<2, MemFun1 >(MemFun(obj, action)); + return MemFunSelectArgImpl<2, MemFun1, ReturnType>(MemFun(obj, action)); } } // namespace FbTk -- cgit v0.11.2