Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49226 - in sandbox/thread_safe_signals/trunk: boost/signals2 boost/signals2/detail libs/signals2/doc/reference
From: fmhess_at_[hidden]
Date: 2008-10-09 17:16:54


Author: fmhess
Date: 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
New Revision: 49226
URL: http://svn.boost.org/trac/boost/changeset/49226

Log:
Got rid of some partial template specialization, for the sake of ancient
compilers using the portable syntax. Tweaked handling of void returns.
Added a description for signalN::slot_result_type.

Added:
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/result_type_wrapper.hpp (contents, props changed)
Text files modified:
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp | 69 ++++++++++++++++++++-------------------
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/signals_common.hpp | 19 -----------
   sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp | 13 +-----
   sandbox/thread_safe_signals/trunk/boost/signals2/optional_last_value.hpp | 11 +----
   sandbox/thread_safe_signals/trunk/boost/signals2/signal.hpp | 5 +-
   sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/signal_header.xml | 8 ++++
   6 files changed, 52 insertions(+), 73 deletions(-)

Added: sandbox/thread_safe_signals/trunk/boost/signals2/detail/result_type_wrapper.hpp
==============================================================================
--- (empty file)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/result_type_wrapper.hpp 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -0,0 +1,47 @@
+// Boost.Signals2 library
+
+// Copyright Douglas Gregor 2001-2004.
+// Copyright Frank Mori Hess 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#ifndef BOOST_SIGNALS2_RESULT_TYPE_WRAPPER_HPP
+#define BOOST_SIGNALS2_RESULT_TYPE_WRAPPER_HPP
+
+#include <boost/config.hpp>
+
+namespace boost {
+ namespace signals2 {
+ namespace detail {
+ // A placeholder for void on compilers that don't support void returns
+ struct void_type {};
+
+ // Replaces void with void_type
+ template<typename R>
+ struct nonvoid {
+ typedef R type;
+ };
+ template<>
+ struct nonvoid<void> {
+ typedef void_type type;
+ };
+
+ // Replaces void with void_type only if compiler doesn't support void returns
+ template<typename R>
+ struct result_type_wrapper {
+ typedef R type;
+ };
+#ifdef BOOST_NO_VOID_RETURNS
+ template<>
+ struct result_type_wrapper<void> {
+ typedef void_type type;
+ };
+#endif
+ } // end namespace detail
+ } // end namespace signals2
+} // end namespace boost
+
+#endif // BOOST_SIGNALS2_RESULT_TYPE_WRAPPER_HPP

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -63,10 +63,11 @@
 
 // bound_extended_slot_functionN
 #define BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N BOOST_PP_CAT(bound_extended_slot_function, BOOST_SIGNALS_NUM_ARGS)
- template<typename ExtendedSlotFunction, typename ResultType>
+ template<typename ExtendedSlotFunction>
         class BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N
       {
       public:
+ typedef typename result_type_wrapper<typename ExtendedSlotFunction::result_type>::type result_type;
         BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N(const ExtendedSlotFunction &fun):
           _fun(fun), _connection(new connection)
         {}
@@ -78,19 +79,21 @@
 #if BOOST_SIGNALS_NUM_ARGS > 0
         template<BOOST_SIGNALS2_MISC_TEMPLATE_DECL>
 #endif // BOOST_SIGNALS_NUM_ARGS > 0
- ResultType operator()(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS))
+ result_type operator()(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS))
         {
- return _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
- BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
+ typename ExtendedSlotFunction::result_type *resolver = 0;
+ return m_invoke(BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS)
+ BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) resolver);
         }
         // const overload
 #if BOOST_SIGNALS_NUM_ARGS > 0
         template<BOOST_SIGNALS2_MISC_TEMPLATE_DECL>
 #endif // BOOST_SIGNALS_NUM_ARGS > 0
- ResultType operator()(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS)) const
+ result_type operator()(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS)) const
         {
- return _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
- BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
+ typename ExtendedSlotFunction::result_type *resolver = 0;
+ return m_invoke(BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS)
+ BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) resolver);
         }
         template<typename T>
           bool operator==(const T &other) const
@@ -100,48 +103,46 @@
       private:
         BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N()
         {}
-
- ExtendedSlotFunction _fun;
- boost::shared_ptr<connection> _connection;
- };
- // specialization for void return type
- template<typename ExtendedSlotFunction>
- class BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N<ExtendedSlotFunction, void>
- {
- public:
- BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N(const ExtendedSlotFunction &fun):
- _fun(fun), _connection(new connection)
- {}
- void set_connection(const connection &conn)
+#if BOOST_SIGNALS_NUM_ARGS > 0
+ template<BOOST_SIGNALS2_MISC_TEMPLATE_DECL>
+#endif // BOOST_SIGNALS_NUM_ARGS > 0
+ result_type m_invoke(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS) BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) ...)
         {
- *_connection = conn;
+ return _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
+ BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
         }
 #if BOOST_SIGNALS_NUM_ARGS > 0
         template<BOOST_SIGNALS2_MISC_TEMPLATE_DECL>
 #endif // BOOST_SIGNALS_NUM_ARGS > 0
- void operator()(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS))
+ result_type m_invoke(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS) BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) const void*)
         {
           _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
             BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
+ return result_type();
         }
- // const overload
+ // const overloads
 #if BOOST_SIGNALS_NUM_ARGS > 0
         template<BOOST_SIGNALS2_MISC_TEMPLATE_DECL>
 #endif // BOOST_SIGNALS_NUM_ARGS > 0
- void operator()(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS)) const
+ result_type m_invoke(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS) BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) ...) const
         {
- _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
+ return _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
             BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
         }
- template<typename T>
- bool operator==(const T &other) const
+#if BOOST_SIGNALS_NUM_ARGS > 0
+ template<BOOST_SIGNALS2_MISC_TEMPLATE_DECL>
+#endif // BOOST_SIGNALS_NUM_ARGS > 0
+ result_type m_invoke(BOOST_SIGNALS2_FULL_REF_ARGS(BOOST_SIGNALS_NUM_ARGS) BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) const void*) const
         {
- return _fun == other;
+ _fun(*_connection BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS)
+ BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
+ return result_type();
         }
- private:
+
         ExtendedSlotFunction _fun;
         boost::shared_ptr<connection> _connection;
       };
+
 #undef BOOST_SIGNALS2_MISC_TEMPLATE_DECL
 #undef BOOST_SIGNALS2_FULL_REF_ARG
 #undef BOOST_SIGNALS2_FULL_REF_ARGS
@@ -164,10 +165,10 @@
         typedef typename group_key<Group>::type group_key_type;
         typedef shared_ptr<connection_body<group_key_type, slot_type, Mutex> > connection_body_type;
         typedef grouped_list<Group, GroupCompare, connection_body_type> connection_list_type;
- typedef BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N<extended_slot_function_type, typename extended_slot_function_type::result_type>
+ typedef BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N<extended_slot_function_type>
           bound_extended_slot_function_type;
       public:
- typedef typename slot_result_type_wrapper<typename slot_function_type::result_type>::type slot_result_type;
+ typedef typename nonvoid<typename slot_function_type::result_type>::type slot_result_type;
         typedef Combiner combiner_type;
         typedef typename combiner_type::result_type result_type;
         typedef Group group_type;
@@ -355,10 +356,10 @@
 #undef BOOST_SIGNAL_MISC_STATEMENT
         private:
           result_type m_invoke(const connection_body_type &connectionBody,
- const unusable *) const
+ const void_type *) const
           {
             connectionBody->slot.slot_function()(BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
- return unusable();
+ return void_type();
           }
           result_type m_invoke(const connection_body_type &connectionBody, ...) const
           {
@@ -634,7 +635,7 @@
       {
       public:
         typedef SlotFunction slot_function_type;
- typedef typename slot_result_type_wrapper<typename slot_function_type::result_type>::type slot_result_type;
+ typedef typename nonvoid<typename slot_function_type::result_type>::type slot_result_type;
         typedef typename BOOST_SIGNAL_CLASS_NAME<BOOST_SIGNAL_TEMPLATE_INSTANTIATION>::result_type
           result_type;
 

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/detail/signals_common.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/detail/signals_common.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/signals_common.hpp 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -20,25 +20,6 @@
 namespace boost {
   namespace signals2 {
     namespace detail {
- // The unusable class is a placeholder for unused function arguments
- // It is also completely unusable except that it constructable from
- // anything. This helps compilers without partial specialization
- // handle slots returning void.
- struct unusable {
- unusable() {}
- };
-
- // Determine the result type of a slot call
- template<typename R>
- struct slot_result_type_wrapper {
- typedef R type;
- };
-
- template<>
- struct slot_result_type_wrapper<void> {
- typedef unusable type;
- };
-
       // Determine if the given type T is a signal
       template<typename T>
       class is_signal: public mpl::bool_<is_base_of<signal_base, T>::value>

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -11,8 +11,8 @@
 #ifndef BOOST_SIGNALS2_LAST_VALUE_HPP
 #define BOOST_SIGNALS2_LAST_VALUE_HPP
 
-#include <cassert>
 #include <boost/optional.hpp>
+#include <boost/signals2/detail/result_type_wrapper.hpp>
 #include <stdexcept>
 
 namespace boost {
@@ -56,17 +56,10 @@
 
     template<>
     class last_value<void> {
- #ifdef BOOST_NO_VOID_RETURNS
- struct unusable {};
     public:
- typedef unusable result_type;
- #else
- public:
- typedef void result_type;
- #endif // BOOST_NO_VOID_RETURNS
+ typedef detail::result_type_wrapper<void>::type result_type;
       template<typename InputIterator>
- result_type
- operator()(InputIterator first, InputIterator last) const
+ result_type operator()(InputIterator first, InputIterator last) const
       {
         while (first != last)
         {

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/optional_last_value.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/optional_last_value.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/optional_last_value.hpp 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -12,11 +12,12 @@
 #define BOOST_SIGNALS2_OPTIONAL_LAST_VALUE_HPP
 
 #include <boost/optional.hpp>
+#include <boost/signals2/detail/result_type_wrapper.hpp>
 
 namespace boost {
   namespace signals2 {
     class expired_slot;
-
+
     template<typename T>
       class optional_last_value
     {
@@ -43,14 +44,8 @@
     template<>
       class optional_last_value<void>
     {
-#ifdef BOOST_NO_VOID_RETURNS
- struct unusable {};
- public:
- typedef unusable result_type;
-#else
     public:
- typedef void result_type;
-#endif // BOOST_NO_VOID_RETURNS
+ typedef detail::result_type_wrapper<void>::type result_type;
       template<typename InputIterator>
         result_type operator()(InputIterator first, InputIterator last) const
       {

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/signal.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/signal.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/signal.hpp 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -19,14 +19,14 @@
 #include <boost/assert.hpp>
 #include <boost/config.hpp>
 #include <boost/function.hpp>
-#include <boost/signals2/optional_last_value.hpp>
 #include <boost/preprocessor/arithmetic.hpp>
 #include <boost/preprocessor/cat.hpp>
 #include <boost/preprocessor/iteration.hpp>
 #include <boost/preprocessor/repetition.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2/detail/unique_lock.hpp>
-#include <boost/type_traits.hpp>
+#include <boost/signals2/optional_last_value.hpp>
+#include <boost/signals2/detail/result_type_wrapper.hpp>
 #include <boost/signals2/detail/signals_common.hpp>
 #include <boost/signals2/detail/signals_common_macros.hpp>
 #include <boost/signals2/detail/slot_groups.hpp>
@@ -35,6 +35,7 @@
 #include <boost/signals2/connection.hpp>
 #include <boost/signals2/shared_connection_block.hpp>
 #include <boost/signals2/slot.hpp>
+#include <boost/type_traits.hpp>
 #include <functional>
 
 namespace boost

Modified: sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/signal_header.xml
==============================================================================
--- sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/signal_header.xml (original)
+++ sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/signal_header.xml 2008-10-09 17:16:54 EDT (Thu, 09 Oct 2008)
@@ -76,6 +76,14 @@
         </typedef>
         <typedef name="slot_result_type">
           <type><emphasis>unspecified</emphasis></type>
+ <description>
+ <para>
+ This is the type returned when dereferencing the input iterators passed to the signal's
+ combiner. It is usually <code>slot_function_type::result_type</code> unless that
+ type is <code>void</code>, in which case <code>slot_result_type</code> is
+ unspecified.
+ </para>
+ </description>
         </typedef>
         <typedef name="slot_call_iterator">
           <type><emphasis>unspecified</emphasis></type>


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