diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-08-02 10:31:53 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-09-14 17:39:11 (GMT) |
commit | 3c050c3d99d5def5bed329c88b966fe0c78fefcc (patch) | |
tree | a75e28e47b1c2131ed82c77dcad073cdb48f20d5 /src | |
parent | e67b9a6f833fd8af3be105ef411f8743d94e25d9 (diff) | |
download | fluxbox-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)
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Slot.hh | 9 |
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 | |||
80 | class SlotImpl: public Slot<ReturnType, Arg1, Arg2, Arg3> { | 80 | class SlotImpl: public Slot<ReturnType, Arg1, Arg2, Arg3> { |
81 | public: | 81 | public: |
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: | |||
92 | template<typename Functor, typename ReturnType, typename Arg1, typename Arg2> | 92 | template<typename Functor, typename ReturnType, typename Arg1, typename Arg2> |
93 | class SlotImpl<Functor, ReturnType, Arg1, Arg2, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1, Arg2> { | 93 | class SlotImpl<Functor, ReturnType, Arg1, Arg2, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1, Arg2> { |
94 | public: | 94 | public: |
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: | |||
104 | template<typename Functor, typename ReturnType, typename Arg1> | 105 | template<typename Functor, typename ReturnType, typename Arg1> |
105 | class SlotImpl<Functor, ReturnType, Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1> { | 106 | class SlotImpl<Functor, ReturnType, Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType, Arg1> { |
106 | public: | 107 | public: |
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: | |||
116 | template<typename Functor, typename ReturnType> | 117 | template<typename Functor, typename ReturnType> |
117 | class SlotImpl<Functor, ReturnType, SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType> { | 118 | class SlotImpl<Functor, ReturnType, SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>: public Slot<ReturnType> { |
118 | public: | 119 | public: |
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 | ||