Patchwork [v3] Minor function::swap clean up

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 4, 2010, 5:30 p.m.
Message ID <4CAA0F23.3020507@oracle.com>
Download mbox | patch
Permalink /patch/66713/
State New
Headers show

Comments

Paolo Carlini - Oct. 4, 2010, 5:30 p.m.
Hi,

I'm working on some C++0x bits of std::function and noticed this
separable tweak.

Tested x86_64-linux, committed.

Paolo.

////////////////////////
2010-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/functional (function<>::swap): Use std::swap.
	* include/tr1/functional (function<>::swap): Likewise.

Patch

Index: include/std/functional
===================================================================
--- include/std/functional	(revision 164946)
+++ include/std/functional	(working copy)
@@ -1940,15 +1940,9 @@ 
        */
       void swap(function& __x)
       {
-	_Any_data __old_functor = _M_functor;
-	_M_functor = __x._M_functor;
-	__x._M_functor = __old_functor;
-	_Manager_type __old_manager = _M_manager;
-	_M_manager = __x._M_manager;
-	__x._M_manager = __old_manager;
-	_Invoker_type __old_invoker = _M_invoker;
-	_M_invoker = __x._M_invoker;
-	__x._M_invoker = __old_invoker;
+	std::swap(_M_functor, __x._M_functor);
+	std::swap(_M_manager, __x._M_manager);
+	std::swap(_M_invoker, __x._M_invoker);
       }
 
       // TODO: needs allocator_arg_t
Index: include/tr1/functional
===================================================================
--- include/tr1/functional	(revision 164927)
+++ include/tr1/functional	(working copy)
@@ -1907,15 +1907,9 @@ 
        */
       void swap(function& __x)
       {
-	_Any_data __old_functor = _M_functor;
-	_M_functor = __x._M_functor;
-	__x._M_functor = __old_functor;
-	_Manager_type __old_manager = _M_manager;
-	_M_manager = __x._M_manager;
-	__x._M_manager = __old_manager;
-	_Invoker_type __old_invoker = _M_invoker;
-	_M_invoker = __x._M_invoker;
-	__x._M_invoker = __old_invoker;
+	std::swap(_M_functor, __x._M_functor);
+	std::swap(_M_manager, __x._M_manager);
+	std::swap(_M_invoker, __x._M_invoker);
       }
 
       // [3.7.2.3] function capacity