$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r84022 - in branches/release: boost/signals2 boost/signals2/detail libs/signals2 libs/signals2/doc/reference libs/signals2/test
From: fmhess_at_[hidden]
Date: 2013-04-22 20:37:29
Author: fmhess
Date: 2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
New Revision: 84022
URL: http://svn.boost.org/trac/boost/changeset/84022
Log:
Merged from trunk.
Properties modified: 
   branches/release/boost/signals2/   (props changed)
   branches/release/libs/signals2/   (props changed)
Text files modified: 
   branches/release/boost/signals2/detail/signal_template.hpp     |    16 +++++++++++++                           
   branches/release/boost/signals2/signal.hpp                     |    21 +++++++++++++++++                       
   branches/release/libs/signals2/doc/reference/connection.xml    |     2                                         
   branches/release/libs/signals2/doc/reference/signal_header.xml |    38 +++++++++++++++++++++++++++++++         
   branches/release/libs/signals2/test/signal_n_test.cpp          |    48 ++++++++++++++++++++++++++++++++++++++++
   branches/release/libs/signals2/test/signal_test.cpp            |    20 ++++++++++++++++                        
   6 files changed, 144 insertions(+), 1 deletions(-)
Modified: branches/release/boost/signals2/detail/signal_template.hpp
==============================================================================
--- branches/release/boost/signals2/detail/signal_template.hpp	(original)
+++ branches/release/boost/signals2/detail/signal_template.hpp	2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
@@ -714,6 +714,11 @@
       {
         return (*_pimpl).set_combiner(combiner_arg);
       }
+      void swap(BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS) & other)
+      {
+        using std::swap;
+        swap(_pimpl, other._pimpl);
+      }
     protected:
       virtual shared_ptr<void> lock_pimpl() const
       {
@@ -724,6 +729,17 @@
         _pimpl;
     };
 
+#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
+    // free swap function for signalN classes, findable by ADL
+    template<BOOST_SIGNALS2_SIGNAL_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS)>
+      void swap(
+        BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS) <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> &sig1,
+        BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS) <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> &sig2 )
+    {
+      sig1.swap(sig2);
+    };
+#endif
+
     namespace detail
     {
       // wrapper class for storing other signals as slots with automatic lifetime tracking
Modified: branches/release/boost/signals2/signal.hpp
==============================================================================
--- branches/release/boost/signals2/signal.hpp	(original)
+++ branches/release/boost/signals2/signal.hpp	2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
@@ -38,4 +38,25 @@
 #include <boost/signals2/variadic_signal.hpp>
 #endif
 
+namespace boost
+{
+  namespace signals2
+  {
+    // free swap function, findable by ADL
+    template<typename Signature,
+      typename Combiner,
+      typename Group,
+      typename GroupCompare,
+      typename SlotFunction,
+      typename ExtendedSlotFunction,
+      typename Mutex>
+      void swap(
+        signal<Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex> &sig1,
+        signal<Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex> &sig2)
+    {
+      sig1.swap(sig2);
+    };
+  }
+}
+
 #endif // BOOST_SIGNALS2_SIGNAL_HPP
Modified: branches/release/libs/signals2/doc/reference/connection.xml
==============================================================================
--- branches/release/libs/signals2/doc/reference/connection.xml	(original)
+++ branches/release/libs/signals2/doc/reference/connection.xml	2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
@@ -104,7 +104,7 @@
           <method name="swap">
             <type>void</type>
             <parameter name="other">
-              <paramtype>const <classname alt="signals2::connection">connection</classname>&</paramtype>
+              <paramtype><classname alt="signals2::connection">connection</classname>&</paramtype>
             </parameter>
             <effects><para>Swaps the connections referenced in
             <computeroutput>this</computeroutput> and
Modified: branches/release/libs/signals2/doc/reference/signal_header.xml
==============================================================================
--- branches/release/libs/signals2/doc/reference/signal_header.xml	(original)
+++ branches/release/libs/signals2/doc/reference/signal_header.xml	2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
@@ -397,6 +397,44 @@
             <throws><para>Will not throw.</para></throws>
           </method>
         </method-group>
+
+        <method-group name="modifiers">
+          <method name="swap">
+            <type>void</type>
+            <parameter name="other">
+              <paramtype><classname alt="signals2::signal">signal</classname>&</paramtype>
+            </parameter>
+            <effects><para>Swaps the signal referenced in
+            <computeroutput>this</computeroutput> and
+            <computeroutput>other</computeroutput>.</para></effects>
+
+            <throws><para>Will not throw.</para></throws>
+          </method>
+        </method-group>
+
+        <free-function-group name="specialized algorithms">
+          <function name="swap">
+            <template>
+              <template-type-parameter name="Signature"/>
+              <template-type-parameter name="Combiner"/>
+              <template-type-parameter name="Group"/>
+              <template-type-parameter name="GroupCompare"/>
+              <template-type-parameter name="SlotFunction"/>
+              <template-type-parameter name="ExtendedSlotFunction"/>
+              <template-type-parameter name="Mutex"/>
+            </template>
+            <type>void</type>
+            <parameter name="x">
+              <paramtype><classname alt="signals2::signal">signal</classname><Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>&</paramtype>
+            </parameter>
+            <parameter name="y">
+              <paramtype><classname alt="signals2::signal">signal</classname><Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>&</paramtype>
+            </parameter>
+
+            <effects><para><computeroutput>x.swap(y)</computeroutput></para></effects>
+            <throws><para>Will not throw.</para></throws>
+          </function>
+        </free-function-group>
       </class>
     </namespace>
   </namespace>
Modified: branches/release/libs/signals2/test/signal_n_test.cpp
==============================================================================
--- branches/release/libs/signals2/test/signal_n_test.cpp	(original)
+++ branches/release/libs/signals2/test/signal_n_test.cpp	2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
@@ -286,6 +286,52 @@
     BOOST_CHECK(sig.num_slots() == 0);
   }
 }
+class dummy_combiner
+{
+public:
+  typedef int result_type;
+
+  dummy_combiner(result_type return_value): _return_value(return_value)
+  {}
+  template<typename SlotIterator>
+  result_type operator()(SlotIterator, SlotIterator)
+  {
+    return _return_value;
+  }
+private:
+  result_type _return_value;
+};
+
+static void
+test_set_combiner()
+{
+  typedef boost::signals2::signal0<int, dummy_combiner> signal_type;
+  signal_type sig(dummy_combiner(0));
+  BOOST_CHECK(sig() == 0);
+  BOOST_CHECK(sig.combiner()(0,0) == 0);
+  sig.set_combiner(dummy_combiner(1));
+  BOOST_CHECK(sig() == 1);
+  BOOST_CHECK(sig.combiner()(0,0) == 1);
+}
+
+static void
+test_swap()
+{
+  typedef boost::signals2::signal0<int, dummy_combiner> signal_type;
+  signal_type sig1(dummy_combiner(1));
+  BOOST_CHECK(sig1() == 1);
+  signal_type sig2(dummy_combiner(2));
+  BOOST_CHECK(sig2() == 2);
+
+  sig1.swap(sig2);
+  BOOST_CHECK(sig1() == 2);
+  BOOST_CHECK(sig2() == 1);
+
+  using std::swap;
+  swap(sig1, sig2);
+  BOOST_CHECK(sig1() == 1);
+  BOOST_CHECK(sig2() == 2);
+}
 
 int
 test_main(int, char* [])
@@ -297,6 +343,8 @@
   test_default_combiner();
   test_extended_slot<void>();
   test_extended_slot<int>();
+  test_set_combiner();
+  test_swap();
   return 0;
 }
 
Modified: branches/release/libs/signals2/test/signal_test.cpp
==============================================================================
--- branches/release/libs/signals2/test/signal_test.cpp	(original)
+++ branches/release/libs/signals2/test/signal_test.cpp	2013-04-22 20:37:28 EDT (Mon, 22 Apr 2013)
@@ -293,6 +293,25 @@
   BOOST_CHECK(sig.combiner()(0,0) == 1);
 }
 
+static void
+test_swap()
+{
+  typedef boost::signals2::signal<int (), dummy_combiner> signal_type;
+  signal_type sig1(dummy_combiner(1));
+  BOOST_CHECK(sig1() == 1);
+  signal_type sig2(dummy_combiner(2));
+  BOOST_CHECK(sig2() == 2);
+
+  sig1.swap(sig2);
+  BOOST_CHECK(sig1() == 2);
+  BOOST_CHECK(sig2() == 1);
+
+  using std::swap;
+  swap(sig1, sig2);
+  BOOST_CHECK(sig1() == 1);
+  BOOST_CHECK(sig2() == 2);
+}
+
 int
 test_main(int, char* [])
 {
@@ -304,5 +323,6 @@
   test_reference_args();
   test_typedefs_etc();
   test_set_combiner();
+  test_swap();
   return 0;
 }