summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0173-2011-04-23-Jonathan-Wakely-jwakely.gcc-gmail.com.patch
blob: 6cd605f79136717930790a6fa3f74c33c6baa793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
Upstream-Status: Inappropriate [Backport]
From 0755fde6008ab7a7ae98f3b4c5967191408431f3 Mon Sep 17 00:00:00 2001
From: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sat, 23 Apr 2011 17:51:31 +0000
Subject: [PATCH 173/200] 2011-04-23  Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR libstdc++/48521
	* include/std/type_traits (result_of): Handle pointer to member.
	* include/std/functional (__invoke): Likewise.
	(_Function_to_function_pointer): Remove.
	(_Reference_wrapper_base): Provide nested types independent of
	unary_function and binary_function.
	(reference_wrapper::operator()): DR 2017.
	(ref(const A&&), cref(const A&&): Define as deleted.
	* include/std/future (async): Simplify SFINAE and use result_of to
	support pointer to member.
	* testsuite/20_util/reference_wrapper/invoke.cc: Test pointer to
	member.
	* testsuite/20_util/reference_wrapper/24803.cc: Likewise.
	* testsuite/20_util/reference_wrapper/typedefs.cc: Test for types
	instead of derivation from unary_function and binary_function.
	* testsuite/20_util/reference_wrapper/invoke-2.cc: New.
	* testsuite/20_util/reference_wrapper/ref_neg.c: New.
	* testsuite/20_util/reference_wrapper/typedefs-3.c: New.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172901 138bc75d-0d04-0410-961f-82ee72b054a4

index 660e371..57ec506 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -212,19 +212,6 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
       static const bool value = sizeof(__test((_Tp*)0)) == 1;
     };
 
-  /// Turns a function type into a function pointer type
-  template<typename _Tp, bool _IsFunctionType = is_function<_Tp>::value>
-    struct _Function_to_function_pointer
-    {
-      typedef _Tp type;
-    };
-
-  template<typename _Tp>
-    struct _Function_to_function_pointer<_Tp, true>
-    {
-      typedef _Tp* type;
-    };
-
   /**
    * Invoke a function object, which may be either a member pointer or a
    * function object. The first parameter will tell which.
@@ -235,20 +222,33 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
 	     (!is_member_pointer<_Functor>::value
 	      && !is_function<_Functor>::value
 	      && !is_function<typename remove_pointer<_Functor>::type>::value),
-	     typename result_of<_Functor(_Args...)>::type
+	     typename result_of<_Functor(_Args&&...)>::type
 	   >::type
     __invoke(_Functor& __f, _Args&&... __args)
     {
       return __f(std::forward<_Args>(__args)...);
     }
 
+  template<typename _Functor, typename... _Args>
+    inline
+    typename enable_if<
+             (is_member_pointer<_Functor>::value
+              && !is_function<_Functor>::value
+              && !is_function<typename remove_pointer<_Functor>::type>::value),
+             typename result_of<_Functor(_Args&&...)>::type
+           >::type
+    __invoke(_Functor& __f, _Args&&... __args)
+    {
+      return mem_fn(__f)(std::forward<_Args>(__args)...);
+    }
+
   // To pick up function references (that will become function pointers)
   template<typename _Functor, typename... _Args>
     inline
     typename enable_if<
 	     (is_pointer<_Functor>::value
 	      && is_function<typename remove_pointer<_Functor>::type>::value),
-	     typename result_of<_Functor(_Args...)>::type
+	     typename result_of<_Functor(_Args&&...)>::type
 	   >::type
     __invoke(_Functor __f, _Args&&... __args)
     {
@@ -263,40 +263,43 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
   template<bool _Unary, bool _Binary, typename _Tp>
     struct _Reference_wrapper_base_impl;
 
-  // Not a unary_function or binary_function, so try a weak result type.
+  // None of the nested argument types.
   template<typename _Tp>
     struct _Reference_wrapper_base_impl<false, false, _Tp>
     : _Weak_result_type<_Tp>
     { };
 
-  // unary_function but not binary_function
+  // Nested argument_type only.
   template<typename _Tp>
     struct _Reference_wrapper_base_impl<true, false, _Tp>
-    : unary_function<typename _Tp::argument_type,
-		     typename _Tp::result_type>
-    { };
+    : _Weak_result_type<_Tp>
+    {
+      typedef typename _Tp::argument_type argument_type;
+    };
 
-  // binary_function but not unary_function
+  // Nested first_argument_type and second_argument_type only.
   template<typename _Tp>
     struct _Reference_wrapper_base_impl<false, true, _Tp>
-    : binary_function<typename _Tp::first_argument_type,
-		      typename _Tp::second_argument_type,
-		      typename _Tp::result_type>
-    { };
+    : _Weak_result_type<_Tp>
+    {
+      typedef typename _Tp::first_argument_type first_argument_type;
+      typedef typename _Tp::second_argument_type second_argument_type;
+    };
 
-  // Both unary_function and binary_function. Import result_type to
-  // avoid conflicts.
+  // All the nested argument types.
    template<typename _Tp>
     struct _Reference_wrapper_base_impl<true, true, _Tp>
-    : unary_function<typename _Tp::argument_type,
-		     typename _Tp::result_type>,
-      binary_function<typename _Tp::first_argument_type,
-		      typename _Tp::second_argument_type,
-		      typename _Tp::result_type>
+    : _Weak_result_type<_Tp>
     {
-      typedef typename _Tp::result_type result_type;
+      typedef typename _Tp::argument_type argument_type;
+      typedef typename _Tp::first_argument_type first_argument_type;
+      typedef typename _Tp::second_argument_type second_argument_type;
     };
 
+  _GLIBCXX_HAS_NESTED_TYPE(argument_type)
+  _GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
+  _GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
+
   /**
    *  Derives from unary_function or binary_function when it
    *  can. Specializations handle all of the easy cases. The primary
@@ -306,8 +309,9 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
   template<typename _Tp>
     struct _Reference_wrapper_base
     : _Reference_wrapper_base_impl<
-      _Derives_from_unary_function<_Tp>::value,
-      _Derives_from_binary_function<_Tp>::value,
+      __has_argument_type<_Tp>::value,
+      __has_first_argument_type<_Tp>::value
+      && __has_second_argument_type<_Tp>::value,
       _Tp>
     { };
 
@@ -422,12 +426,8 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
     class reference_wrapper
     : public _Reference_wrapper_base<typename remove_cv<_Tp>::type>
     {
-      // If _Tp is a function type, we can't form result_of<_Tp(...)>,
-      // so turn it into a function pointer type.
-      typedef typename _Function_to_function_pointer<_Tp>::type
-	_M_func_type;
-
       _Tp* _M_data;
+
     public:
       typedef _Tp type;
 
@@ -456,7 +456,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
       { return *_M_data; }
 
       template<typename... _Args>
-	typename result_of<_M_func_type(_Args...)>::type
+	typename result_of<_Tp&(_Args&&...)>::type
 	operator()(_Args&&... __args) const
 	{
 	  return __invoke(get(), std::forward<_Args>(__args)...);
@@ -476,6 +476,12 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
     cref(const _Tp& __t)
     { return reference_wrapper<const _Tp>(__t); }
 
+  template<typename _Tp>
+    void ref(const _Tp&&) = delete;
+
+  template<typename _Tp>
+    void cref(const _Tp&&) = delete;
+
   /// Partial specialization.
   template<typename _Tp>
     inline reference_wrapper<_Tp>
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 17d46db..970ce76 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -142,11 +142,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     future<typename result_of<_Fn(_Args...)>::type>
     async(launch __policy, _Fn&& __fn, _Args&&... __args);
 
+  template<typename _FnCheck, typename _Fn, typename... _Args>
+    struct __async_sfinae_helper
+    {
+      typedef future<typename result_of<_Fn(_Args...)>::type> type;
+    };
+
+  template<typename _Fn, typename... _Args>
+    struct __async_sfinae_helper<launch, _Fn, _Args...>
+    { };
+
   template<typename _Fn, typename... _Args>
     typename
-    enable_if<!is_same<typename decay<_Fn>::type, launch>::value,
-              future<decltype(std::declval<_Fn>()(std::declval<_Args>()...))>
-             >::type
+    __async_sfinae_helper<typename decay<_Fn>::type, _Fn, _Args...>::type
     async(_Fn&& __fn, _Args&&... __args);
 
 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
@@ -1366,9 +1374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// async, potential overload
   template<typename _Fn, typename... _Args>
     inline typename
-    enable_if<!is_same<typename decay<_Fn>::type, launch>::value,
-              future<decltype(std::declval<_Fn>()(std::declval<_Args>()...))>
-             >::type
+    __async_sfinae_helper<typename decay<_Fn>::type, _Fn, _Args...>::type
     async(_Fn&& __fn, _Args&&... __args)
     {
       return async(launch::any, std::forward<_Fn>(__fn),
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index f5d867b..2361152 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1140,12 +1140,92 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Signature>
     class result_of;
 
+  template<typename _MemPtr, typename _Arg>
+    struct _Result_of_memobj;
+
+  template<typename _Res, typename _Class, typename _Arg>
+    struct _Result_of_memobj<_Res _Class::*, _Arg>
+    {
+    private:
+      typedef _Res _Class::* _Func;
+
+      template<typename _Tp>
+	static _Tp _S_get(const _Class&);
+      template<typename _Tp>
+	static decltype(*std::declval<_Tp>()) _S_get(...);
+        
+    public:
+      typedef
+        decltype(_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
+        __type;
+    };
+
+  template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
+    struct _Result_of_memfun;
+
+  template<typename _Res, typename _Class, typename _Arg, typename... _Args>
+    struct _Result_of_memfun<_Res _Class::*, _Arg, _Args...>
+    {
+    private:
+      typedef _Res _Class::* _Func;
+
+      template<typename _Tp>
+	static _Tp _S_get(const _Class&);
+      template<typename _Tp>
+	static decltype(*std::declval<_Tp>()) _S_get(...);
+        
+    public:
+      typedef
+        decltype((_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
+            (std::declval<_Args>()...) )
+        __type;
+    };
+
+  template<bool, bool, typename _Functor, typename... _ArgTypes>
+    struct _Result_of_impl;
+
   template<typename _Functor, typename... _ArgTypes>
-    struct result_of<_Functor(_ArgTypes...)>
+    struct _Result_of_impl<false, false, _Functor, _ArgTypes...>
     {
       typedef
         decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) )
-        type;
+        __type;
+    };
+
+  template<typename _MemPtr, typename _Arg>
+    struct _Result_of_impl<true, false, _MemPtr, _Arg>
+    : _Result_of_memobj<typename remove_reference<_MemPtr>::type, _Arg>
+    {
+      typedef typename _Result_of_memobj<
+	typename remove_reference<_MemPtr>::type, _Arg>::__type
+	__type;
+    };
+
+  template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
+    struct _Result_of_impl<false, true, _MemPtr, _Arg, _ArgTypes...>
+    : _Result_of_memfun<typename remove_reference<_MemPtr>::type, _Arg,
+                        _ArgTypes...>
+    {
+      typedef typename _Result_of_memfun<
+	typename remove_reference<_MemPtr>::type, _Arg, _ArgTypes...>::__type
+	__type;
+    };
+
+  template<typename _Functor, typename... _ArgTypes>
+    struct result_of<_Functor(_ArgTypes...)>
+    : _Result_of_impl<is_member_object_pointer<
+                        typename remove_reference<_Functor>::type >::value,
+                      is_member_function_pointer<
+			typename remove_reference<_Functor>::type >::value,
+		      _Functor, _ArgTypes...>
+    {
+      typedef typename _Result_of_impl<
+	is_member_object_pointer<
+	  typename remove_reference<_Functor>::type >::value,
+        is_member_function_pointer<
+	  typename remove_reference<_Functor>::type >::value,
+       	_Functor, _ArgTypes...>::__type
+	type;
     };
 
   /**
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
index 598c5c8..4bf6148 100644
--- a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // { dg-do compile }
 
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -46,12 +46,18 @@ void verify_return_type(T, T)
 
 void test01()
 {
+  test_type* null_tt = 0;
+  const test_type* null_ttc = 0;
   int zero;
 
   std::reference_wrapper<double (int)>* pr1(0);
   verify_return_type((*pr1)(0), double());
   std::reference_wrapper<double (*)(int)>* pr2(0);
   verify_return_type((*pr2)(0), double());
+  std::reference_wrapper<int (test_type::*)()>* pr3(0);
+  verify_return_type((*pr3)(null_tt), int());
+  std::reference_wrapper<int (test_type::*)()const>* pr4(0);
+  verify_return_type((*pr4)(null_ttc), int());
   std::reference_wrapper<functor1>* pr5(0);
 
   // libstdc++/24803
@@ -62,6 +68,10 @@ void test01()
   verify_return_type((*pr1b)(0, 0), double());
   std::reference_wrapper<double (*)(int, char)>* pr2b(0);
   verify_return_type((*pr2b)(0, 0), double());
+  std::reference_wrapper<int (test_type::*)(char)>* pr3b(0);
+  verify_return_type((*pr3b)(null_tt,zero), int());
+  std::reference_wrapper<int (test_type::*)()const>* pr4b(0);
+  verify_return_type((*pr4b)(null_ttc), int());
   std::reference_wrapper<functor2>* pr5b(0);
 
   // libstdc++/24803
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc
new file mode 100644
index 0000000..bd9aeb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile}
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.6.4 function object return types [func.ret]
+#include <functional>
+
+struct X
+{
+    int f(int) { return 0; }
+    int i;
+};
+
+void test01()
+{
+  typedef int (X::*mfp)(int);
+  typedef int X::*mp;
+  mfp m = &X::f;
+  mp m2 = &X::i;
+  X x = { };
+  std::ref(m)(x, 1);
+  std::ref(m)(&x, 1);
+  int& i1 = std::ref(m2)(x);
+  int& i2 = std::ref(m2)(&x);
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
index b371f1c..7b694c7 100644
--- a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
@@ -1,6 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -36,6 +36,7 @@ struct X
   int foo_c(float x)  const          { return truncate_float(x); }
   int foo_v(float x)  volatile       { return truncate_float(x); }
   int foo_cv(float x) const volatile { return truncate_float(x); }
+  int foo_varargs(float x, ...)      { return truncate_float(x); }
 
   int operator()(float x)
   {
@@ -69,6 +70,13 @@ void test01()
 
   ::get_seventeen get_sev;
   ::X x;
+  ::X* xp = &x;
+  int (::X::* p_foo)(float) = &::X::foo;
+  int (::X::* p_foo_c)(float) const = &::X::foo_c;
+  int (::X::* p_foo_v)(float) volatile = &::X::foo_v;
+  int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv;
+  int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs;
+  int ::X::* p_bar = &::X::bar;
 
   const float pi = 3.14;
 
@@ -77,8 +85,26 @@ void test01()
   VERIFY(ref(seventeen)() == 17);
 
   // Function pointers
-  VERIFY(cref(&truncate_float)(pi) == 3);
-  VERIFY(cref(&seventeen)() == 17);
+  VERIFY(cref(truncate_float)(pi) == 3);
+  VERIFY(cref(seventeen)() == 17);
+
+  // Member function pointers
+  VERIFY(ref(p_foo)(x, pi) == 3);
+  VERIFY(ref(p_foo)(xp, pi) == 3);
+  VERIFY(ref(p_foo_c)(x, pi) == 3);
+  VERIFY(ref(p_foo_c)(xp, pi) == 3);
+  VERIFY(ref(p_foo_v)(x, pi) == 3);
+  VERIFY(ref(p_foo_v)(xp, pi) == 3);
+  VERIFY(ref(p_foo_cv)(x, pi) == 3);
+  VERIFY(ref(p_foo_cv)(xp, pi) == 3);
+  // VERIFY(ref(p_foo_varargs)(x, pi) == 3);
+  // VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3);
+  // VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3);
+  // VERIFY(ref(p_foo_varargs)(xp, pi) == 3);
+
+  // Member data pointers
+  VERIFY(ref(p_bar)(x) == 17);
+  VERIFY(ref(p_bar)(xp) == 17);
 
   // Function objects
   VERIFY(ref(get_sev)() == 17);
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc
new file mode 100644
index 0000000..947a9b0
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.8.3 Class template reference_wrapper
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <functional>
+
+struct X { };
+X rval();
+X&& rvalref();
+
+void test01()
+{
+  std::ref(1);          // { dg-error "deleted" }
+  std::cref(1);         // { dg-error "deleted" }
+  std::ref( int() );    // { dg-error "deleted" }
+  std::cref( int() );   // { dg-error "deleted" }
+  std::ref(rval());     // { dg-error "deleted" }
+  std::cref(rvalref()); // { dg-error "deleted" }
+}
+
+int main()
+{
+  test02();
+}
+
+// { dg-excess-errors "" }
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
new file mode 100644
index 0000000..2fea52e
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
@@ -0,0 +1,148 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <functional>
+#include <type_traits>
+
+struct S { };
+
+struct S0
+{
+  typedef int argument_type;
+};
+
+struct S1
+{
+  typedef float first_argument_type;
+};
+
+struct S2
+{
+  typedef char second_argument_type;
+};
+
+struct S01 : S0, S1 { };
+struct S02 : S0, S2 { };
+struct S12 : S1, S2 { };
+
+struct S012 : S0, S1, S2 { };
+
+using std::__sfinae_types;
+using std::integral_constant;
+using std::remove_cv;
+
+_GLIBCXX_HAS_NESTED_TYPE(argument_type)
+_GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
+_GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
+
+template<typename T>
+  struct has_arg_type : __has_argument_type<T>
+  { };
+
+template<typename T>
+  struct has_1st_arg_type : __has_first_argument_type<T>
+  { };
+
+template<typename T>
+  struct has_2nd_arg_type : __has_second_argument_type<T>
+  { };
+
+template<typename T, bool = has_arg_type<T>::value>
+struct test_arg_type
+{
+  static_assert( !has_arg_type<std::reference_wrapper<T>>::value,
+      "reference_wrapper has no nested argument_type");
+};
+
+template<typename T>
+struct test_arg_type<T, true>
+{
+  typedef std::reference_wrapper<T> ref;
+
+  static_assert( has_arg_type<ref>::value,
+      "reference_wrapper has nested argument_type");
+
+  static_assert(
+      std::is_same< typename T::argument_type,
+                    typename ref::argument_type >::value,
+      "reference_wrapper has the correct argument_type");
+};
+
+template<typename T,
+         bool = has_1st_arg_type<T>::value && has_2nd_arg_type<T>::value>
+struct test_1st_2nd_arg_types
+{
+  typedef std::reference_wrapper<T> ref;
+
+  static_assert( !has_1st_arg_type<ref>::value,
+      "reference_wrapper has no nested first_argument_type");
+
+  static_assert( !has_2nd_arg_type<ref>::value,
+      "reference_wrapper has no nested second_argument_type");
+};
+
+template<typename T>
+struct test_1st_2nd_arg_types<T, true>
+{
+  typedef std::reference_wrapper<T> ref;
+
+  static_assert( has_1st_arg_type<ref>::value,
+      "reference_wrapper has nested first_argument_type");
+
+  static_assert( has_2nd_arg_type<ref>::value,
+      "reference_wrapper has nested second_argument_type");
+
+  static_assert(
+      std::is_same< typename T::first_argument_type,
+                    typename ref::first_argument_type>::value,
+      "reference_wrapper has correct first_argument_type");
+
+  static_assert(
+      std::is_same< typename T::second_argument_type,
+                    typename ref::second_argument_type>::value,
+      "reference_wrapper has correct second_argument_type");
+};
+
+
+template<typename T>
+  void test()
+  {
+    test_arg_type<T> t;
+    test_arg_type<const T> tc;
+    test_arg_type<volatile T> tv;
+    test_arg_type<const volatile T> tcv;
+    test_1st_2nd_arg_types<T> t12;
+    test_1st_2nd_arg_types<const T> t12c;
+    test_1st_2nd_arg_types<volatile T> t12v;
+    test_1st_2nd_arg_types<const volatile T> t12cv;
+  }
+
+int main()
+{
+  test<S>();
+  test<S0>();
+  test<S1>();
+  test<S2>();
+  test<S01>();
+  test<S02>();
+  test<S12>();
+  test<S012>();
+}
+
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
index 56ee29e..815700f 100644
--- a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
@@ -1,6 +1,7 @@
+// { dg-do compile }
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -19,10 +20,6 @@
 
 #include <functional>
 #include <type_traits>
-#include <testsuite_hooks.h>
-#include <testsuite_tr1.h>
-
-using namespace __gnu_test;
 
 struct X {};
 
@@ -41,43 +38,18 @@ struct derives_unary_binary
 
 void test01()
 {
-  bool test __attribute__((unused)) = true;
-
   using std::reference_wrapper;
   using std::is_same;
-  using std::is_convertible;
-  using std::unary_function;
-  using std::binary_function;
 
   // Check result_type typedef
-  VERIFY((is_same<reference_wrapper<int_result_type>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<derives_unary>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<derives_binary>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<int(void)>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<int(*)(void)>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value));
-  VERIFY((is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value));
-
-  // Check derivation from unary_function
-  VERIFY((is_convertible<reference_wrapper<derives_unary>*, unary_function<int, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<derives_unary_binary>*, unary_function<int, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int(int)>*, unary_function<int, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int(*)(int)>*, unary_function<int, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)()>*, unary_function< ::X*, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)() const>*, unary_function<const ::X*, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)() volatile>*, unary_function<volatile ::X*, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)() const volatile>*, unary_function<const volatile ::X*, int>*>::value));
-
-  // Check derivation from binary_function
-  VERIFY((is_convertible<reference_wrapper<derives_binary>*, binary_function<int, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<derives_unary_binary>*, binary_function<int, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int(int, float)>*, binary_function<int, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int(*)(int, float)>*, binary_function<int, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float)>*, binary_function< ::X*, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) const>*, binary_function<const ::X*, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) volatile>*, binary_function<volatile ::X*, float, int>*>::value));
-  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) const volatile>*, binary_function<const volatile ::X*, float, int>*>::value));
+  static_assert( is_same<reference_wrapper<int_result_type>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<derives_unary>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<derives_binary>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<int(void)>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<int(*)(void)>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value, "has result_type" );
+  static_assert( is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value, "has result_type" );
 }
 
 int main()
-- 
1.7.0.4

OpenPOWER on IntegriCloud