aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-02 10:31:53 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-09-14 17:39:11 (GMT)
commit3c050c3d99d5def5bed329c88b966fe0c78fefcc (patch)
treea75e28e47b1c2131ed82c77dcad073cdb48f20d5
parente67b9a6f833fd8af3be105ef411f8743d94e25d9 (diff)
downloadfluxbox-3c050c3d99d5def5bed329c88b966fe0c78fefcc.zip
fluxbox-3c050c3d99d5def5bed329c88b966fe0c78fefcc.tar.bz2
Add explicit ReturnType cast to operator() of FbTk::Slots
without this it wasn't possible to construct a Slot returning void from functors returning some real value because the compiler would complain about "return statement with a value in a function returning void". Theoretically, this may produce some unexpected type conversions, because static_cast is slightly stronger than implicit cast, but I judge the risk to be negligable (the alternative would be to provide explicit specializations for slots returning void - too much typing)
-rw-r--r--src/FbTk/Slot.hh9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/FbTk/Slot.hh b/src/FbTk/Slot.hh
index 71bf6ab..23be197 100644
--- a/src/FbTk/Slot.hh
+++ b/src/FbTk/Slot.hh
@@ -80,7 +80,7 @@ template<typename Functor, typename ReturnType, typename Arg1 = SigImpl::EmptyAr
80class SlotImpl: public Slot<ReturnType, Arg1, Arg2, Arg3> { 80class SlotImpl: public Slot<ReturnType, Arg1, Arg2, Arg3> {
81public: 81public:
82 virtual ReturnType operator()(Arg1 arg1, Arg2 arg2, Arg3 arg3) 82 virtual ReturnType operator()(Arg1 arg1, Arg2 arg2, Arg3 arg3)
83 { return m_functor(arg1, arg2, arg3); } 83 { return static_cast<ReturnType>(m_functor(arg1, arg2, arg3)); }
84 84
85 SlotImpl(Functor functor) : m_functor(functor) {} 85 SlotImpl(Functor functor) : m_functor(functor) {}
86 86
@@ -92,7 +92,8 @@ private:
92template<typename Functor, typename ReturnType, typename Arg1, typename Arg2> 92template<typename Functor, typename ReturnType, typename Arg1, typename Arg2>
93class SlotImpl<Functor, ReturnType, Arg1, Arg2, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1, Arg2> { 93class SlotImpl<Functor, ReturnType, Arg1, Arg2, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1, Arg2> {
94public: 94public:
95 virtual ReturnType operator()(Arg1 arg1, Arg2 arg2) { return m_functor(arg1, arg2); } 95 virtual ReturnType operator()(Arg1 arg1, Arg2 arg2)
96 { return static_cast<ReturnType>(m_functor(arg1, arg2)); }
96 97
97 SlotImpl(Functor functor) : m_functor(functor) {} 98 SlotImpl(Functor functor) : m_functor(functor) {}
98 99
@@ -104,7 +105,7 @@ private:
104template<typename Functor, typename ReturnType, typename Arg1> 105template<typename Functor, typename ReturnType, typename Arg1>
105class SlotImpl<Functor, ReturnType, Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1> { 106class SlotImpl<Functor, ReturnType, Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1> {
106public: 107public:
107 virtual ReturnType operator()(Arg1 arg1) { return m_functor(arg1); } 108 virtual ReturnType operator()(Arg1 arg1) { return static_cast<ReturnType>(m_functor(arg1)); }
108 109
109 SlotImpl(Functor functor) : m_functor(functor) {} 110 SlotImpl(Functor functor) : m_functor(functor) {}
110 111
@@ -116,7 +117,7 @@ private:
116template<typename Functor, typename ReturnType> 117template<typename Functor, typename ReturnType>
117class SlotImpl<Functor, ReturnType, SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType> { 118class SlotImpl<Functor, ReturnType, SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType> {
118public: 119public:
119 virtual ReturnType operator()() { return m_functor(); } 120 virtual ReturnType operator()() { return static_cast<ReturnType>(m_functor()); }
120 121
121 SlotImpl(Functor functor) : m_functor(functor) {} 122 SlotImpl(Functor functor) : m_functor(functor) {}
122 123