1This patch was generated from the headers installed by MacPorts
2gcc-4.4 on OS X 10.6.  You can apply it there with
3`cd /opt/local/include/gcc44/c++ ; sudo patch -p1 <this_patch`, or similar
4on other operating systems.  Mail cfe-dev if you find other problems in the
5standard headers.
6
7This patch is offered under the same modified GPLv3 as libstdc++-4.4.
8
9diff -ur a/bits/forward_list.h b/bits/forward_list.h
10--- a/bits/forward_list.h	2011-03-15 14:49:05.000000000 -0700
11+++ b/bits/forward_list.h	2011-05-02 23:51:33.000000000 -0700
12@@ -983,7 +983,7 @@
13        *  function.
14        */
15       void
16-      swap(forward_list&& __list)
17+      swap(forward_list& __list)
18       { _Node_base::swap(this->_M_impl._M_head, __list._M_impl._M_head); }
19
20       /**
21diff -ur a/bits/move.h b/bits/move.h
22--- a/bits/move.h	2011-03-15 14:49:05.000000000 -0700
23+++ b/bits/move.h	2011-03-29 10:33:39.000000000 -0700
24@@ -48,13 +48,35 @@
25
26   template<typename _Tp>
27     inline _Tp&&
28-    forward(typename std::identity<_Tp>::type&& __t)
29+    forward(typename std::remove_reference<_Tp>::type& __t)
30+#ifdef __clang__
31+    { return static_cast<_Tp&&>(__t); }
32+#else
33     { return __t; }
34+#endif
35+
36+  template<typename _Tp>
37+    inline _Tp&&
38+    forward(typename std::remove_reference<_Tp>::type&& __t)
39+    {
40+#ifdef __clang__
41+      static_assert(!std::is_lvalue_reference<_Tp>::value,
42+                    "Can't instantiate this forward() with an"
43+                    " lvalue reference type.");
44+      return static_cast<_Tp&&>(__t);
45+#else
46+      return __t;
47+#endif
48+    }
49
50   template<typename _Tp>
51     inline typename std::remove_reference<_Tp>::type&&
52     move(_Tp&& __t)
53+#ifdef __clang__
54+    { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
55+#else
56     { return __t; }
57+#endif
58
59 _GLIBCXX_END_NAMESPACE
60
61diff -ur a/bits/shared_ptr.h b/bits/shared_ptr.h
62--- a/bits/shared_ptr.h	2011-03-15 14:49:05.000000000 -0700
63+++ b/bits/shared_ptr.h	2011-03-31 16:40:45.000000000 -0700
64@@ -833,7 +833,7 @@
65       { return _M_refcount._M_get_use_count(); }
66
67       void
68-      swap(__shared_ptr<_Tp, _Lp>&& __other) // never throws
69+      swap(__shared_ptr<_Tp, _Lp>& __other) // never throws
70       {
71 	std::swap(_M_ptr, __other._M_ptr);
72 	_M_refcount._M_swap(__other._M_refcount);
73@@ -943,16 +943,6 @@
74     swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b)
75     { __a.swap(__b); }
76
77-  template<typename _Tp, _Lock_policy _Lp>
78-    inline void
79-    swap(__shared_ptr<_Tp, _Lp>&& __a, __shared_ptr<_Tp, _Lp>& __b)
80-    { __a.swap(__b); }
81-
82-  template<typename _Tp, _Lock_policy _Lp>
83-    inline void
84-    swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>&& __b)
85-    { __a.swap(__b); }
86-
87   // 2.2.3.9 shared_ptr casts
88   /** @warning The seemingly equivalent
89    *           <code>shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get()))</code>
90@@ -1372,16 +1362,6 @@
91     swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
92     { __a.swap(__b); }
93
94-  template<typename _Tp>
95-    inline void
96-    swap(shared_ptr<_Tp>&& __a, shared_ptr<_Tp>& __b)
97-    { __a.swap(__b); }
98-
99-  template<typename _Tp>
100-    inline void
101-    swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>&& __b)
102-    { __a.swap(__b); }
103-
104   // 20.8.13.2.10 shared_ptr casts.
105   template<typename _Tp, typename _Tp1>
106     inline shared_ptr<_Tp>
107diff -ur a/bits/stl_bvector.h b/bits/stl_bvector.h
108--- a/bits/stl_bvector.h	2011-03-15 14:49:05.000000000 -0700
109+++ b/bits/stl_bvector.h	2011-05-02 23:34:46.000000000 -0700
110@@ -743,11 +743,7 @@
111     }
112
113     void
114-#ifdef __GXX_EXPERIMENTAL_CXX0X__
115-    swap(vector&& __x)
116-#else
117     swap(vector& __x)
118-#endif
119     {
120       std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
121       std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
122diff -ur a/bits/stl_deque.h b/bits/stl_deque.h
123--- a/bits/stl_deque.h	2011-03-15 14:49:05.000000000 -0700
124+++ b/bits/stl_deque.h	2011-03-29 10:33:39.000000000 -0700
125@@ -1395,11 +1395,7 @@
126        *  std::swap(d1,d2) will feed to this function.
127        */
128       void
129-#ifdef __GXX_EXPERIMENTAL_CXX0X__
130-      swap(deque&& __x)
131-#else
132       swap(deque& __x)
133-#endif
134       {
135 	std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
136 	std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
137diff -ur a/bits/stl_iterator.h b/bits/stl_iterator.h
138--- a/bits/stl_iterator.h	2011-03-15 14:49:05.000000000 -0700
139+++ b/bits/stl_iterator.h	2011-03-29 10:33:39.000000000 -0700
140@@ -913,7 +913,7 @@
141
142       reference
143       operator*() const
144-      { return *_M_current; }
145+      { return std::move(*_M_current); }
146
147       pointer
148       operator->() const
149diff -ur a/bits/stl_list.h b/bits/stl_list.h
150--- a/bits/stl_list.h	2011-03-15 14:49:05.000000000 -0700
151+++ b/bits/stl_list.h	2011-03-29 10:33:39.000000000 -0700
152@@ -1106,11 +1106,7 @@
153        *  function.
154        */
155       void
156-#ifdef __GXX_EXPERIMENTAL_CXX0X__
157-      swap(list&& __x)
158-#else
159       swap(list& __x)
160-#endif
161       {
162 	_List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node);
163
164@@ -1160,6 +1156,12 @@
165 	  }
166       }
167
168+#ifdef __GXX_EXPERIMENTAL_CXX0X__
169+      void
170+      splice(iterator __position, list& __x)
171+      { splice(__position, std::move(__x)); }
172+#endif
173+
174       /**
175        *  @brief  Insert element from another %list.
176        *  @param  position  Iterator referencing the element to insert before.
177@@ -1187,6 +1189,12 @@
178 	this->_M_transfer(__position, __i, __j);
179       }
180
181+#ifdef __GXX_EXPERIMENTAL_CXX0X__
182+      void
183+      splice(iterator __position, list& __x, iterator __i)
184+      { splice(__position, std::move(__x), __i); }
185+#endif
186+
187       /**
188        *  @brief  Insert range from another %list.
189        *  @param  position  Iterator referencing the element to insert before.
190@@ -1217,6 +1225,13 @@
191 	  }
192       }
193
194+#ifdef __GXX_EXPERIMENTAL_CXX0X__
195+      void
196+      splice(iterator __position, list& __x, iterator __first,
197+	     iterator __last)
198+      { splice(__position, std::move(__x), __first, __last); }
199+#endif
200+
201       /**
202        *  @brief  Remove all elements equal to value.
203        *  @param  value  The value to remove.
204@@ -1287,6 +1302,10 @@
205       void
206 #ifdef __GXX_EXPERIMENTAL_CXX0X__
207       merge(list&& __x);
208+
209+      void
210+      merge(list& __x)
211+      { merge(std::move(__x)); }
212 #else
213       merge(list& __x);
214 #endif
215@@ -1307,6 +1326,11 @@
216         void
217 #ifdef __GXX_EXPERIMENTAL_CXX0X__
218         merge(list&&, _StrictWeakOrdering);
219+
220+      template<typename _StrictWeakOrdering>
221+        void
222+        merge(list& __l, _StrictWeakOrdering __comp)
223+        { merge(std::move(__l), __comp); }
224 #else
225         merge(list&, _StrictWeakOrdering);
226 #endif
227diff -ur a/bits/stl_map.h b/bits/stl_map.h
228--- a/bits/stl_map.h	2011-03-15 14:49:05.000000000 -0700
229+++ b/bits/stl_map.h	2011-03-29 10:33:39.000000000 -0700
230@@ -608,11 +608,7 @@
231        *  that std::swap(m1,m2) will feed to this function.
232        */
233       void
234-#ifdef __GXX_EXPERIMENTAL_CXX0X__
235-      swap(map&& __x)
236-#else
237       swap(map& __x)
238-#endif
239       { _M_t.swap(__x._M_t); }
240
241       /**
242diff -ur a/bits/stl_multimap.h b/bits/stl_multimap.h
243--- a/bits/stl_multimap.h	2011-03-15 14:49:05.000000000 -0700
244+++ b/bits/stl_multimap.h	2011-03-29 10:33:39.000000000 -0700
245@@ -544,11 +544,7 @@
246        *  std::swap(m1,m2) will feed to this function.
247        */
248       void
249-#ifdef __GXX_EXPERIMENTAL_CXX0X__
250-      swap(multimap&& __x)
251-#else
252       swap(multimap& __x)
253-#endif
254       { _M_t.swap(__x._M_t); }
255
256       /**
257diff -ur a/bits/stl_multiset.h b/bits/stl_multiset.h
258--- a/bits/stl_multiset.h	2011-03-15 14:49:05.000000000 -0700
259+++ b/bits/stl_multiset.h	2011-03-29 10:33:39.000000000 -0700
260@@ -376,11 +376,7 @@
261        *  std::swap(s1,s2) will feed to this function.
262        */
263       void
264-#ifdef __GXX_EXPERIMENTAL_CXX0X__
265-      swap(multiset&& __x)
266-#else
267       swap(multiset& __x)
268-#endif
269       { _M_t.swap(__x._M_t); }
270
271       // insert/erase
272diff -ur a/bits/stl_pair.h b/bits/stl_pair.h
273--- a/bits/stl_pair.h	2011-03-15 14:49:05.000000000 -0700
274+++ b/bits/stl_pair.h	2011-03-29 10:33:39.000000000 -0700
275@@ -84,10 +84,21 @@
276       : first(__a), second(__b) { }
277
278 #ifdef __GXX_EXPERIMENTAL_CXX0X__
279-      template<class _U1, class _U2>
280+      template<class _U1, class = typename
281+	       std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
282+	pair(_U1&& __x, const _T2& __y)
283+	: first(std::forward<_U1>(__x)), second(__y) { }
284+
285+      template<class _U2, class = typename
286+	       std::enable_if<std::is_convertible<_U2, _T2>::value>::type>
287+	pair(const _T1& __x, _U2&& __y)
288+	: first(__x), second(std::forward<_U2>(__y)) { }
289+
290+      template<class _U1, class _U2, class = typename
291+	       std::enable_if<std::is_convertible<_U1, _T1>::value
292+			      && std::is_convertible<_U2, _T2>::value>::type>
293         pair(_U1&& __x, _U2&& __y)
294-	: first(std::forward<_U1>(__x)),
295-	  second(std::forward<_U2>(__y)) { }
296+	: first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
297
298       pair(pair&& __p)
299       : first(std::move(__p.first)),
300@@ -107,11 +118,19 @@
301 	  second(std::move(__p.second)) { }
302
303       // http://gcc.gnu.org/ml/libstdc++/2007-08/msg00052.html
304+
305+#if 0
306+      // This constructor is incompatible with libstdc++-4.6, and it
307+      // interferes with passing NULL pointers to the 2-argument
308+      // constructors, so we disable it.  map::emplace isn't
309+      // implemented in libstdc++-4.4 anyway, and that's what this
310+      // constructor was here for.
311       template<class _U1, class _Arg0, class... _Args>
312         pair(_U1&& __x, _Arg0&& __arg0, _Args&&... __args)
313 	: first(std::forward<_U1>(__x)),
314 	  second(std::forward<_Arg0>(__arg0),
315 		 std::forward<_Args>(__args)...) { }
316+#endif
317
318       pair&
319       operator=(pair&& __p)
320@@ -131,7 +150,7 @@
321 	}
322
323       void
324-      swap(pair&& __p)
325+      swap(pair& __p)
326       {
327 	using std::swap;
328 	swap(first, __p.first);
329diff -ur a/bits/stl_queue.h b/bits/stl_queue.h
330--- a/bits/stl_queue.h	2011-03-15 14:49:05.000000000 -0700
331+++ b/bits/stl_queue.h	2011-05-02 23:36:15.000000000 -0700
332@@ -249,7 +249,7 @@
333
334 #ifdef __GXX_EXPERIMENTAL_CXX0X__
335       void
336-      swap(queue&& __q)
337+      swap(queue& __q)
338       { c.swap(__q.c); }
339 #endif
340     };
341@@ -550,7 +550,7 @@
342
343 #ifdef __GXX_EXPERIMENTAL_CXX0X__
344       void
345-      swap(priority_queue&& __pq)
346+      swap(priority_queue& __pq)
347       {
348 	using std::swap;
349 	c.swap(__pq.c);
350diff -ur a/bits/stl_set.h b/bits/stl_set.h
351--- a/bits/stl_set.h	2011-03-15 14:49:05.000000000 -0700
352+++ b/bits/stl_set.h	2011-03-29 10:33:39.000000000 -0700
353@@ -383,11 +383,7 @@
354        *  std::swap(s1,s2) will feed to this function.
355        */
356       void
357-#ifdef __GXX_EXPERIMENTAL_CXX0X__
358-      swap(set&& __x)
359-#else
360       swap(set& __x)
361-#endif
362       { _M_t.swap(__x._M_t); }
363
364       // insert/erase
365diff -ur a/bits/stl_stack.h b/bits/stl_stack.h
366--- a/bits/stl_stack.h	2011-03-15 14:49:05.000000000 -0700
367+++ b/bits/stl_stack.h	2011-05-02 23:36:36.000000000 -0700
368@@ -213,7 +213,7 @@
369
370 #ifdef __GXX_EXPERIMENTAL_CXX0X__
371       void
372-      swap(stack&& __s)
373+      swap(stack& __s)
374       { c.swap(__s.c); }
375 #endif
376     };
377diff -ur a/bits/stl_tree.h b/bits/stl_tree.h
378--- a/bits/stl_tree.h	2011-03-15 14:49:05.000000000 -0700
379+++ b/bits/stl_tree.h	2011-03-29 10:33:39.000000000 -0700
380@@ -675,11 +675,7 @@
381       { return _M_get_Node_allocator().max_size(); }
382
383       void
384-#ifdef __GXX_EXPERIMENTAL_CXX0X__
385-      swap(_Rb_tree&& __t);
386-#else
387       swap(_Rb_tree& __t);
388-#endif
389
390       // Insert/erase.
391       pair<iterator, bool>
392@@ -1104,11 +1100,7 @@
393            typename _Compare, typename _Alloc>
394     void
395     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
396-#ifdef __GXX_EXPERIMENTAL_CXX0X__
397-    swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&& __t)
398-#else
399     swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t)
400-#endif
401     {
402       if (_M_root() == 0)
403 	{
404diff -ur a/bits/stl_vector.h b/bits/stl_vector.h
405--- a/bits/stl_vector.h	2011-03-15 14:49:05.000000000 -0700
406+++ b/bits/stl_vector.h	2011-03-29 10:33:39.000000000 -0700
407@@ -923,11 +923,7 @@
408        *  std::swap(v1,v2) will feed to this function.
409        */
410       void
411-#ifdef __GXX_EXPERIMENTAL_CXX0X__
412-      swap(vector&& __x)
413-#else
414       swap(vector& __x)
415-#endif
416       {
417 	std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
418 	std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
419diff -ur a/bits/unique_ptr.h b/bits/unique_ptr.h
420--- a/bits/unique_ptr.h	2011-03-15 14:49:05.000000000 -0700
421+++ b/bits/unique_ptr.h	2011-03-31 16:40:45.000000000 -0700
422@@ -204,7 +204,7 @@
423       }
424
425       void
426-      swap(unique_ptr&& __u)
427+      swap(unique_ptr& __u)
428       {
429 	using std::swap;
430 	swap(_M_t, __u._M_t);
431@@ -350,7 +350,7 @@
432         void reset(_Up) = delete;
433
434       void
435-      swap(unique_ptr&& __u)
436+      swap(unique_ptr& __u)
437       {
438 	using std::swap;
439 	swap(_M_t, __u._M_t);
440@@ -389,18 +389,6 @@
441 	 unique_ptr<_Tp, _Tp_Deleter>& __y)
442     { __x.swap(__y); }
443
444-  template<typename _Tp, typename _Tp_Deleter>
445-    inline void
446-    swap(unique_ptr<_Tp, _Tp_Deleter>&& __x,
447-	 unique_ptr<_Tp, _Tp_Deleter>& __y)
448-    { __x.swap(__y); }
449-
450-  template<typename _Tp, typename _Tp_Deleter>
451-    inline void
452-    swap(unique_ptr<_Tp, _Tp_Deleter>& __x,
453-	 unique_ptr<_Tp, _Tp_Deleter>&& __y)
454-    { __x.swap(__y); }
455-
456   template<typename _Tp, typename _Tp_Deleter,
457 	   typename _Up, typename _Up_Deleter>
458     inline bool
459diff -ur a/exception_ptr.h b/exception_ptr.h
460--- a/exception_ptr.h	2011-03-15 14:49:08.000000000 -0700
461+++ b/exception_ptr.h	2011-03-29 10:33:39.000000000 -0700
462@@ -140,7 +140,7 @@
463       friend bool
464       operator==(const exception_ptr&, const exception_ptr&) throw();
465
466-      const type_info*
467+      const class type_info*
468       __cxa_exception_type() const throw();
469     };
470
471diff -ur a/ext/algorithm b/ext/algorithm
472--- a/ext/algorithm	2011-03-15 14:49:05.000000000 -0700
473+++ b/ext/algorithm	2011-03-29 10:33:39.000000000 -0700
474@@ -423,6 +423,9 @@
475 			     __out_last - __out_first);
476     }
477
478+#ifdef __GXX_EXPERIMENTAL_CXX0X__
479+  using std::is_heap;
480+#else
481   /**
482    *  This is an SGI extension.
483    *  @ingroup SGIextensions
484@@ -462,6 +465,7 @@
485
486       return std::__is_heap(__first, __comp, __last - __first);
487     }
488+#endif
489
490   // is_sorted, a predicated testing whether a range is sorted in
491   // nondescending order.  This is an extension, not part of the C++
492diff -ur a/ext/vstring.h b/ext/vstring.h
493--- a/ext/vstring.h	2011-03-15 14:49:05.000000000 -0700
494+++ b/ext/vstring.h	2011-03-29 10:33:39.000000000 -0700
495@@ -152,7 +152,7 @@
496        *  string.
497        */
498       __versa_string(__versa_string&& __str)
499-      : __vstring_base(std::forward<__vstring_base>(__str)) { }
500+      : __vstring_base(std::move(__str)) { }
501
502       /**
503        *  @brief  Construct string from an initializer list.
504@@ -1439,11 +1439,7 @@
505        *  constant time.
506       */
507       void
508-#ifdef __GXX_EXPERIMENTAL_CXX0X__
509-      swap(__versa_string&& __s)
510-#else
511       swap(__versa_string& __s)
512-#endif
513       { this->_M_swap(__s); }
514
515       // String operations:
516diff -ur a/tr1_impl/hashtable b/tr1_impl/hashtable
517--- a/tr1_impl/hashtable	2011-03-15 14:49:07.000000000 -0700
518+++ b/tr1_impl/hashtable	2011-05-02 23:41:55.000000000 -0700
519@@ -225,11 +225,7 @@
520
521       ~_Hashtable();
522
523-#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
524-      void swap(_Hashtable&&);
525-#else
526       void swap(_Hashtable&);
527-#endif
528
529       // Basic container operations
530       iterator
531@@ -732,11 +728,7 @@
532     void
533     _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
534 	       _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
535-#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
536-    swap(_Hashtable&& __x)
537-#else
538     swap(_Hashtable& __x)
539-#endif
540     {
541       // The only base class with member variables is hash_code_base.  We
542       // define _Hash_code_base::_M_swap because different specializations
543diff -ur a/tuple b/tuple
544--- a/tuple	2011-03-15 14:49:07.000000000 -0700
545+++ b/tuple	2011-05-02 23:33:23.000000000 -0700
546@@ -77,7 +77,7 @@
547       _Head&       _M_head()       { return *this; }
548       const _Head& _M_head() const { return *this; }
549
550-      void _M_swap_impl(_Head&&) { /* no-op */ }
551+      void _M_swap_impl(_Head&) { /* no-op */ }
552     };
553
554   template<std::size_t _Idx, typename _Head>
555@@ -97,7 +97,7 @@
556       const _Head& _M_head() const { return _M_head_impl; }
557
558       void
559-      _M_swap_impl(_Head&& __h)
560+      _M_swap_impl(_Head& __h)
561       {
562 	using std::swap;
563 	swap(__h, _M_head_impl);
564@@ -125,7 +125,7 @@
565     struct _Tuple_impl<_Idx>
566     {
567     protected:
568-      void _M_swap_impl(_Tuple_impl&&) { /* no-op */ }
569+      void _M_swap_impl(_Tuple_impl&) { /* no-op */ }
570     };
571
572   /**
573@@ -214,7 +214,7 @@
574
575     protected:
576       void
577-      _M_swap_impl(_Tuple_impl&& __in)
578+      _M_swap_impl(_Tuple_impl& __in)
579       {
580 	_Base::_M_swap_impl(__in._M_head());
581 	_Inherited::_M_swap_impl(__in._M_tail());
582@@ -292,7 +292,7 @@
583 	}
584
585       void
586-      swap(tuple&& __in)
587+      swap(tuple& __in)
588       { _Inherited::_M_swap_impl(__in); }
589     };
590
591@@ -301,7 +301,7 @@
592     class tuple<>
593     {
594     public:
595-      void swap(tuple&&) { /* no-op */ }
596+      void swap(tuple&) { /* no-op */ }
597     };
598
599   /// tuple (2-element), with construction and assignment from a pair.
600@@ -394,7 +394,7 @@
601 	}
602
603       void
604-      swap(tuple&& __in)
605+      swap(tuple& __in)
606       {
607 	using std::swap;
608 	swap(this->_M_head(), __in._M_head());
609