From 3c050c3d99d5def5bed329c88b966fe0c78fefcc Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 2 Aug 2011 12:31:53 +0200 Subject: 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) --- src/FbTk/Slot.hh | 9 +++++---- 1 file 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 { public: virtual ReturnType operator()(Arg1 arg1, Arg2 arg2, Arg3 arg3) - { return m_functor(arg1, arg2, arg3); } + { return static_cast(m_functor(arg1, arg2, arg3)); } SlotImpl(Functor functor) : m_functor(functor) {} @@ -92,7 +92,8 @@ private: template class SlotImpl: public Slot { public: - virtual ReturnType operator()(Arg1 arg1, Arg2 arg2) { return m_functor(arg1, arg2); } + virtual ReturnType operator()(Arg1 arg1, Arg2 arg2) + { return static_cast(m_functor(arg1, arg2)); } SlotImpl(Functor functor) : m_functor(functor) {} @@ -104,7 +105,7 @@ private: template class SlotImpl: public Slot { public: - virtual ReturnType operator()(Arg1 arg1) { return m_functor(arg1); } + virtual ReturnType operator()(Arg1 arg1) { return static_cast(m_functor(arg1)); } SlotImpl(Functor functor) : m_functor(functor) {} @@ -116,7 +117,7 @@ private: template class SlotImpl: public Slot { public: - virtual ReturnType operator()() { return m_functor(); } + virtual ReturnType operator()() { return static_cast(m_functor()); } SlotImpl(Functor functor) : m_functor(functor) {} -- cgit v0.11.2