Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53400 - in trunk/boost/signals2: . detail
From: fmhess_at_[hidden]
Date: 2009-05-29 13:35:36


Author: fmhess
Date: 2009-05-29 13:35:35 EDT (Fri, 29 May 2009)
New Revision: 53400
URL: http://svn.boost.org/trac/boost/changeset/53400

Log:
Make combiners that return void work, even when
BOOST_NO_VOID_RETURNS is defined. Stopped slot_result_type
from being dishonest when slot returns void and BOOST_NO_VOID_RETURNS
is defined.

Text files modified:
   trunk/boost/signals2/detail/result_type_wrapper.hpp | 25 +++++++++++++++++++++++++
   trunk/boost/signals2/detail/signal_template.hpp | 25 ++++++++++++-------------
   trunk/boost/signals2/last_value.hpp | 5 ++---
   trunk/boost/signals2/optional_last_value.hpp | 5 ++---
   4 files changed, 41 insertions(+), 19 deletions(-)

Modified: trunk/boost/signals2/detail/result_type_wrapper.hpp
==============================================================================
--- trunk/boost/signals2/detail/result_type_wrapper.hpp (original)
+++ trunk/boost/signals2/detail/result_type_wrapper.hpp 2009-05-29 13:35:35 EDT (Fri, 29 May 2009)
@@ -40,6 +40,31 @@
         typedef void_type type;
       };
 #endif
+
+ // specialization deals with possible void return from combiners
+ template<typename R> class combiner_invoker
+ {
+ public:
+ typedef R result_type;
+ template<typename Combiner, typename InputIterator>
+ result_type operator()(Combiner &combiner,
+ InputIterator first, InputIterator last) const
+ {
+ return combiner(first, last);
+ }
+ };
+ template<> class combiner_invoker<void>
+ {
+ public:
+ typedef result_type_wrapper<void>::type result_type;
+ template<typename Combiner, typename InputIterator>
+ result_type operator()(Combiner &combiner,
+ InputIterator first, InputIterator last) const
+ {
+ combiner(first, last);
+ return result_type();
+ }
+ };
     } // end namespace detail
   } // end namespace signals2
 } // end namespace boost

Modified: trunk/boost/signals2/detail/signal_template.hpp
==============================================================================
--- trunk/boost/signals2/detail/signal_template.hpp (original)
+++ trunk/boost/signals2/detail/signal_template.hpp 2009-05-29 13:35:35 EDT (Fri, 29 May 2009)
@@ -131,12 +131,12 @@
         typedef ExtendedSlotFunction extended_slot_function_type;
         // typedef slotN+1<R, const connection &, T1, T2, ..., TN, extended_slot_function_type> extended_slot_type;
         typedef BOOST_SIGNALS2_EXTENDED_SLOT_TYPE(BOOST_SIGNALS2_NUM_ARGS) extended_slot_type;
- typedef typename nonvoid<typename slot_function_type::result_type>::type slot_result_type;
+ typedef typename nonvoid<typename slot_function_type::result_type>::type nonvoid_slot_result_type;
       private:
 #ifdef BOOST_NO_VARIADIC_TEMPLATES
         class slot_invoker;
 #else // BOOST_NO_VARIADIC_TEMPLATES
- typedef variadic_slot_invoker<slot_result_type, Args...> slot_invoker;
+ typedef variadic_slot_invoker<nonvoid_slot_result_type, Args...> slot_invoker;
 #endif // BOOST_NO_VARIADIC_TEMPLATES
         typedef typename group_key<Group>::type group_key_type;
         typedef shared_ptr<connection_body<group_key_type, slot_type, Mutex> > connection_body_type;
@@ -145,7 +145,7 @@
           bound_extended_slot_function_type;
       public:
         typedef Combiner combiner_type;
- typedef typename combiner_type::result_type result_type;
+ typedef typename result_type_wrapper<typename combiner_type::result_type>::type result_type;
         typedef Group group_type;
         typedef GroupCompare group_compare_type;
         typedef typename detail::slot_call_iterator_t<slot_invoker,
@@ -236,8 +236,8 @@
             local_state = _shared_state;
           }
           slot_invoker invoker = slot_invoker(BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(BOOST_SIGNALS2_NUM_ARGS));
- slot_call_iterator_cache<slot_result_type, slot_invoker> cache(invoker);
- return local_state->combiner()(
+ slot_call_iterator_cache<nonvoid_slot_result_type, slot_invoker> cache(invoker);
+ return detail::combiner_invoker<typename combiner_type::result_type>()(local_state->combiner(),
             slot_call_iterator(local_state->connection_bodies().begin(), local_state->connection_bodies().end(), cache),
             slot_call_iterator(local_state->connection_bodies().end(), local_state->connection_bodies().end(), cache));
         }
@@ -256,8 +256,8 @@
             local_state = _shared_state;
           }
           slot_invoker invoker = slot_invoker(BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(BOOST_SIGNALS2_NUM_ARGS));
- slot_call_iterator_cache<slot_result_type, slot_invoker> cache(invoker);
- return local_state->combiner()(
+ slot_call_iterator_cache<nonvoid_slot_result_type, slot_invoker> cache(invoker);
+ return detail::combiner_invoker<typename combiner_type::result_type>()(local_state->combiner(),
             slot_call_iterator(local_state->connection_bodies().begin(), local_state->connection_bodies().end(), cache),
             slot_call_iterator(local_state->connection_bodies().end(), local_state->connection_bodies().end(), cache));
         }
@@ -307,7 +307,7 @@
         class slot_invoker
         {
         public:
- typedef slot_result_type result_type;
+ typedef nonvoid_slot_result_type result_type;
           slot_invoker(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS2_NUM_ARGS)) BOOST_PP_IF(BOOST_SIGNALS2_NUM_ARGS, :, )
 // argn ( argn ) ,
 #define BOOST_SIGNALS2_MISC_STATEMENT(z, n, data) \
@@ -513,7 +513,8 @@
     template<BOOST_SIGNALS2_SIGNAL_TEMPLATE_SPECIALIZATION_DECL(BOOST_SIGNALS2_NUM_ARGS)>
     class BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
       BOOST_SIGNALS2_SIGNAL_TEMPLATE_SPECIALIZATION: public signal_base,
- public detail::BOOST_SIGNALS2_STD_FUNCTIONAL_BASE(typename Combiner::result_type)
+ public detail::BOOST_SIGNALS2_STD_FUNCTIONAL_BASE
+ (typename detail::result_type_wrapper<typename Combiner::result_type>::type)
     {
       typedef detail::BOOST_SIGNALS2_SIGNAL_IMPL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
         <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> impl_class;
@@ -528,9 +529,9 @@
       typedef typename impl_class::slot_type slot_type;
       typedef typename impl_class::extended_slot_function_type extended_slot_function_type;
       typedef typename impl_class::extended_slot_type extended_slot_type;
- typedef typename impl_class::slot_result_type slot_result_type;
+ typedef typename slot_function_type::result_type slot_result_type;
       typedef Combiner combiner_type;
- typedef typename combiner_type::result_type result_type;
+ typedef typename impl_class::result_type result_type;
       typedef Group group_type;
       typedef GroupCompare group_compare_type;
       typedef typename impl_class::slot_call_iterator
@@ -654,8 +655,6 @@
         BOOST_SIGNALS2_SIGNAL_TEMPLATE_SPECIALIZATION
       {
       public:
- typedef SlotFunction slot_function_type;
- typedef typename nonvoid<typename slot_function_type::result_type>::type slot_result_type;
         typedef typename BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
           <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION>::result_type
           result_type;

Modified: trunk/boost/signals2/last_value.hpp
==============================================================================
--- trunk/boost/signals2/last_value.hpp (original)
+++ trunk/boost/signals2/last_value.hpp 2009-05-29 13:35:35 EDT (Fri, 29 May 2009)
@@ -12,7 +12,6 @@
 #define BOOST_SIGNALS2_LAST_VALUE_HPP
 
 #include <boost/optional.hpp>
-#include <boost/signals2/detail/result_type_wrapper.hpp>
 #include <boost/throw_exception.hpp>
 #include <stdexcept>
 
@@ -59,7 +58,7 @@
     template<>
     class last_value<void> {
     public:
- typedef detail::result_type_wrapper<void>::type result_type;
+ typedef void result_type;
       template<typename InputIterator>
         result_type operator()(InputIterator first, InputIterator last) const
       {
@@ -72,7 +71,7 @@
           catch(const expired_slot &) {}
           ++first;
         }
- return result_type();
+ return;
       }
     };
   } // namespace signals2

Modified: trunk/boost/signals2/optional_last_value.hpp
==============================================================================
--- trunk/boost/signals2/optional_last_value.hpp (original)
+++ trunk/boost/signals2/optional_last_value.hpp 2009-05-29 13:35:35 EDT (Fri, 29 May 2009)
@@ -12,7 +12,6 @@
 #define BOOST_SIGNALS2_OPTIONAL_LAST_VALUE_HPP
 
 #include <boost/optional.hpp>
-#include <boost/signals2/detail/result_type_wrapper.hpp>
 
 namespace boost {
   namespace signals2 {
@@ -45,7 +44,7 @@
       class optional_last_value<void>
     {
     public:
- typedef detail::result_type_wrapper<void>::type result_type;
+ typedef void result_type;
       template<typename InputIterator>
         result_type operator()(InputIterator first, InputIterator last) const
       {
@@ -58,7 +57,7 @@
           catch(const expired_slot &) {}
           ++first;
         }
- return result_type();
+ return;
       }
     };
   } // namespace signals2


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk