]> code.ossystems Code Review - openembedded-core.git/blob
6cd605f79136717930790a6fa3f74c33c6baa793
[openembedded-core.git] /
1 Upstream-Status: Inappropriate [Backport]
2 From 0755fde6008ab7a7ae98f3b4c5967191408431f3 Mon Sep 17 00:00:00 2001
3 From: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Sat, 23 Apr 2011 17:51:31 +0000
5 Subject: [PATCH 173/200] 2011-04-23  Jonathan Wakely  <jwakely.gcc@gmail.com>
6
7         PR libstdc++/48521
8         * include/std/type_traits (result_of): Handle pointer to member.
9         * include/std/functional (__invoke): Likewise.
10         (_Function_to_function_pointer): Remove.
11         (_Reference_wrapper_base): Provide nested types independent of
12         unary_function and binary_function.
13         (reference_wrapper::operator()): DR 2017.
14         (ref(const A&&), cref(const A&&): Define as deleted.
15         * include/std/future (async): Simplify SFINAE and use result_of to
16         support pointer to member.
17         * testsuite/20_util/reference_wrapper/invoke.cc: Test pointer to
18         member.
19         * testsuite/20_util/reference_wrapper/24803.cc: Likewise.
20         * testsuite/20_util/reference_wrapper/typedefs.cc: Test for types
21         instead of derivation from unary_function and binary_function.
22         * testsuite/20_util/reference_wrapper/invoke-2.cc: New.
23         * testsuite/20_util/reference_wrapper/ref_neg.c: New.
24         * testsuite/20_util/reference_wrapper/typedefs-3.c: New.
25
26
27
28 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172901 138bc75d-0d04-0410-961f-82ee72b054a4
29
30 index 660e371..57ec506 100644
31 --- a/libstdc++-v3/include/std/functional
32 +++ b/libstdc++-v3/include/std/functional
33 @@ -212,19 +212,6 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
34        static const bool value = sizeof(__test((_Tp*)0)) == 1;
35      };
36  
37 -  /// Turns a function type into a function pointer type
38 -  template<typename _Tp, bool _IsFunctionType = is_function<_Tp>::value>
39 -    struct _Function_to_function_pointer
40 -    {
41 -      typedef _Tp type;
42 -    };
43 -
44 -  template<typename _Tp>
45 -    struct _Function_to_function_pointer<_Tp, true>
46 -    {
47 -      typedef _Tp* type;
48 -    };
49 -
50    /**
51     * Invoke a function object, which may be either a member pointer or a
52     * function object. The first parameter will tell which.
53 @@ -235,20 +222,33 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
54              (!is_member_pointer<_Functor>::value
55               && !is_function<_Functor>::value
56               && !is_function<typename remove_pointer<_Functor>::type>::value),
57 -            typename result_of<_Functor(_Args...)>::type
58 +            typename result_of<_Functor(_Args&&...)>::type
59            >::type
60      __invoke(_Functor& __f, _Args&&... __args)
61      {
62        return __f(std::forward<_Args>(__args)...);
63      }
64  
65 +  template<typename _Functor, typename... _Args>
66 +    inline
67 +    typename enable_if<
68 +             (is_member_pointer<_Functor>::value
69 +              && !is_function<_Functor>::value
70 +              && !is_function<typename remove_pointer<_Functor>::type>::value),
71 +             typename result_of<_Functor(_Args&&...)>::type
72 +           >::type
73 +    __invoke(_Functor& __f, _Args&&... __args)
74 +    {
75 +      return mem_fn(__f)(std::forward<_Args>(__args)...);
76 +    }
77 +
78    // To pick up function references (that will become function pointers)
79    template<typename _Functor, typename... _Args>
80      inline
81      typename enable_if<
82              (is_pointer<_Functor>::value
83               && is_function<typename remove_pointer<_Functor>::type>::value),
84 -            typename result_of<_Functor(_Args...)>::type
85 +            typename result_of<_Functor(_Args&&...)>::type
86            >::type
87      __invoke(_Functor __f, _Args&&... __args)
88      {
89 @@ -263,40 +263,43 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
90    template<bool _Unary, bool _Binary, typename _Tp>
91      struct _Reference_wrapper_base_impl;
92  
93 -  // Not a unary_function or binary_function, so try a weak result type.
94 +  // None of the nested argument types.
95    template<typename _Tp>
96      struct _Reference_wrapper_base_impl<false, false, _Tp>
97      : _Weak_result_type<_Tp>
98      { };
99  
100 -  // unary_function but not binary_function
101 +  // Nested argument_type only.
102    template<typename _Tp>
103      struct _Reference_wrapper_base_impl<true, false, _Tp>
104 -    : unary_function<typename _Tp::argument_type,
105 -                    typename _Tp::result_type>
106 -    { };
107 +    : _Weak_result_type<_Tp>
108 +    {
109 +      typedef typename _Tp::argument_type argument_type;
110 +    };
111  
112 -  // binary_function but not unary_function
113 +  // Nested first_argument_type and second_argument_type only.
114    template<typename _Tp>
115      struct _Reference_wrapper_base_impl<false, true, _Tp>
116 -    : binary_function<typename _Tp::first_argument_type,
117 -                     typename _Tp::second_argument_type,
118 -                     typename _Tp::result_type>
119 -    { };
120 +    : _Weak_result_type<_Tp>
121 +    {
122 +      typedef typename _Tp::first_argument_type first_argument_type;
123 +      typedef typename _Tp::second_argument_type second_argument_type;
124 +    };
125  
126 -  // Both unary_function and binary_function. Import result_type to
127 -  // avoid conflicts.
128 +  // All the nested argument types.
129     template<typename _Tp>
130      struct _Reference_wrapper_base_impl<true, true, _Tp>
131 -    : unary_function<typename _Tp::argument_type,
132 -                    typename _Tp::result_type>,
133 -      binary_function<typename _Tp::first_argument_type,
134 -                     typename _Tp::second_argument_type,
135 -                     typename _Tp::result_type>
136 +    : _Weak_result_type<_Tp>
137      {
138 -      typedef typename _Tp::result_type result_type;
139 +      typedef typename _Tp::argument_type argument_type;
140 +      typedef typename _Tp::first_argument_type first_argument_type;
141 +      typedef typename _Tp::second_argument_type second_argument_type;
142      };
143  
144 +  _GLIBCXX_HAS_NESTED_TYPE(argument_type)
145 +  _GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
146 +  _GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
147 +
148    /**
149     *  Derives from unary_function or binary_function when it
150     *  can. Specializations handle all of the easy cases. The primary
151 @@ -306,8 +309,9 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
152    template<typename _Tp>
153      struct _Reference_wrapper_base
154      : _Reference_wrapper_base_impl<
155 -      _Derives_from_unary_function<_Tp>::value,
156 -      _Derives_from_binary_function<_Tp>::value,
157 +      __has_argument_type<_Tp>::value,
158 +      __has_first_argument_type<_Tp>::value
159 +      && __has_second_argument_type<_Tp>::value,
160        _Tp>
161      { };
162  
163 @@ -422,12 +426,8 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
164      class reference_wrapper
165      : public _Reference_wrapper_base<typename remove_cv<_Tp>::type>
166      {
167 -      // If _Tp is a function type, we can't form result_of<_Tp(...)>,
168 -      // so turn it into a function pointer type.
169 -      typedef typename _Function_to_function_pointer<_Tp>::type
170 -       _M_func_type;
171 -
172        _Tp* _M_data;
173 +
174      public:
175        typedef _Tp type;
176  
177 @@ -456,7 +456,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
178        { return *_M_data; }
179  
180        template<typename... _Args>
181 -       typename result_of<_M_func_type(_Args...)>::type
182 +       typename result_of<_Tp&(_Args&&...)>::type
183         operator()(_Args&&... __args) const
184         {
185           return __invoke(get(), std::forward<_Args>(__args)...);
186 @@ -476,6 +476,12 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
187      cref(const _Tp& __t)
188      { return reference_wrapper<const _Tp>(__t); }
189  
190 +  template<typename _Tp>
191 +    void ref(const _Tp&&) = delete;
192 +
193 +  template<typename _Tp>
194 +    void cref(const _Tp&&) = delete;
195 +
196    /// Partial specialization.
197    template<typename _Tp>
198      inline reference_wrapper<_Tp>
199 diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
200 index 17d46db..970ce76 100644
201 --- a/libstdc++-v3/include/std/future
202 +++ b/libstdc++-v3/include/std/future
203 @@ -142,11 +142,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
204      future<typename result_of<_Fn(_Args...)>::type>
205      async(launch __policy, _Fn&& __fn, _Args&&... __args);
206  
207 +  template<typename _FnCheck, typename _Fn, typename... _Args>
208 +    struct __async_sfinae_helper
209 +    {
210 +      typedef future<typename result_of<_Fn(_Args...)>::type> type;
211 +    };
212 +
213 +  template<typename _Fn, typename... _Args>
214 +    struct __async_sfinae_helper<launch, _Fn, _Args...>
215 +    { };
216 +
217    template<typename _Fn, typename... _Args>
218      typename
219 -    enable_if<!is_same<typename decay<_Fn>::type, launch>::value,
220 -              future<decltype(std::declval<_Fn>()(std::declval<_Args>()...))>
221 -             >::type
222 +    __async_sfinae_helper<typename decay<_Fn>::type, _Fn, _Args...>::type
223      async(_Fn&& __fn, _Args&&... __args);
224  
225  #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
226 @@ -1366,9 +1374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
227    /// async, potential overload
228    template<typename _Fn, typename... _Args>
229      inline typename
230 -    enable_if<!is_same<typename decay<_Fn>::type, launch>::value,
231 -              future<decltype(std::declval<_Fn>()(std::declval<_Args>()...))>
232 -             >::type
233 +    __async_sfinae_helper<typename decay<_Fn>::type, _Fn, _Args...>::type
234      async(_Fn&& __fn, _Args&&... __args)
235      {
236        return async(launch::any, std::forward<_Fn>(__fn),
237 diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
238 index f5d867b..2361152 100644
239 --- a/libstdc++-v3/include/std/type_traits
240 +++ b/libstdc++-v3/include/std/type_traits
241 @@ -1140,12 +1140,92 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
242    template<typename _Signature>
243      class result_of;
244  
245 +  template<typename _MemPtr, typename _Arg>
246 +    struct _Result_of_memobj;
247 +
248 +  template<typename _Res, typename _Class, typename _Arg>
249 +    struct _Result_of_memobj<_Res _Class::*, _Arg>
250 +    {
251 +    private:
252 +      typedef _Res _Class::* _Func;
253 +
254 +      template<typename _Tp>
255 +       static _Tp _S_get(const _Class&);
256 +      template<typename _Tp>
257 +       static decltype(*std::declval<_Tp>()) _S_get(...);
258 +        
259 +    public:
260 +      typedef
261 +        decltype(_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
262 +        __type;
263 +    };
264 +
265 +  template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
266 +    struct _Result_of_memfun;
267 +
268 +  template<typename _Res, typename _Class, typename _Arg, typename... _Args>
269 +    struct _Result_of_memfun<_Res _Class::*, _Arg, _Args...>
270 +    {
271 +    private:
272 +      typedef _Res _Class::* _Func;
273 +
274 +      template<typename _Tp>
275 +       static _Tp _S_get(const _Class&);
276 +      template<typename _Tp>
277 +       static decltype(*std::declval<_Tp>()) _S_get(...);
278 +        
279 +    public:
280 +      typedef
281 +        decltype((_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
282 +            (std::declval<_Args>()...) )
283 +        __type;
284 +    };
285 +
286 +  template<bool, bool, typename _Functor, typename... _ArgTypes>
287 +    struct _Result_of_impl;
288 +
289    template<typename _Functor, typename... _ArgTypes>
290 -    struct result_of<_Functor(_ArgTypes...)>
291 +    struct _Result_of_impl<false, false, _Functor, _ArgTypes...>
292      {
293        typedef
294          decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) )
295 -        type;
296 +        __type;
297 +    };
298 +
299 +  template<typename _MemPtr, typename _Arg>
300 +    struct _Result_of_impl<true, false, _MemPtr, _Arg>
301 +    : _Result_of_memobj<typename remove_reference<_MemPtr>::type, _Arg>
302 +    {
303 +      typedef typename _Result_of_memobj<
304 +       typename remove_reference<_MemPtr>::type, _Arg>::__type
305 +       __type;
306 +    };
307 +
308 +  template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
309 +    struct _Result_of_impl<false, true, _MemPtr, _Arg, _ArgTypes...>
310 +    : _Result_of_memfun<typename remove_reference<_MemPtr>::type, _Arg,
311 +                        _ArgTypes...>
312 +    {
313 +      typedef typename _Result_of_memfun<
314 +       typename remove_reference<_MemPtr>::type, _Arg, _ArgTypes...>::__type
315 +       __type;
316 +    };
317 +
318 +  template<typename _Functor, typename... _ArgTypes>
319 +    struct result_of<_Functor(_ArgTypes...)>
320 +    : _Result_of_impl<is_member_object_pointer<
321 +                        typename remove_reference<_Functor>::type >::value,
322 +                      is_member_function_pointer<
323 +                       typename remove_reference<_Functor>::type >::value,
324 +                     _Functor, _ArgTypes...>
325 +    {
326 +      typedef typename _Result_of_impl<
327 +       is_member_object_pointer<
328 +         typename remove_reference<_Functor>::type >::value,
329 +        is_member_function_pointer<
330 +         typename remove_reference<_Functor>::type >::value,
331 +               _Functor, _ArgTypes...>::__type
332 +       type;
333      };
334  
335    /**
336 diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
337 index 598c5c8..4bf6148 100644
338 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
339 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
340 @@ -1,7 +1,7 @@
341  // { dg-options "-std=gnu++0x" }
342  // { dg-do compile }
343  
344 -// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
345 +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
346  //
347  // This file is part of the GNU ISO C++ Library.  This library is free
348  // software; you can redistribute it and/or modify it under the
349 @@ -46,12 +46,18 @@ void verify_return_type(T, T)
350  
351  void test01()
352  {
353 +  test_type* null_tt = 0;
354 +  const test_type* null_ttc = 0;
355    int zero;
356  
357    std::reference_wrapper<double (int)>* pr1(0);
358    verify_return_type((*pr1)(0), double());
359    std::reference_wrapper<double (*)(int)>* pr2(0);
360    verify_return_type((*pr2)(0), double());
361 +  std::reference_wrapper<int (test_type::*)()>* pr3(0);
362 +  verify_return_type((*pr3)(null_tt), int());
363 +  std::reference_wrapper<int (test_type::*)()const>* pr4(0);
364 +  verify_return_type((*pr4)(null_ttc), int());
365    std::reference_wrapper<functor1>* pr5(0);
366  
367    // libstdc++/24803
368 @@ -62,6 +68,10 @@ void test01()
369    verify_return_type((*pr1b)(0, 0), double());
370    std::reference_wrapper<double (*)(int, char)>* pr2b(0);
371    verify_return_type((*pr2b)(0, 0), double());
372 +  std::reference_wrapper<int (test_type::*)(char)>* pr3b(0);
373 +  verify_return_type((*pr3b)(null_tt,zero), int());
374 +  std::reference_wrapper<int (test_type::*)()const>* pr4b(0);
375 +  verify_return_type((*pr4b)(null_ttc), int());
376    std::reference_wrapper<functor2>* pr5b(0);
377  
378    // libstdc++/24803
379 diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc
380 new file mode 100644
381 index 0000000..bd9aeb2
382 --- /dev/null
383 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc
384 @@ -0,0 +1,47 @@
385 +// { dg-options "-std=gnu++0x" }
386 +// { dg-do compile}
387 +// Copyright (C) 2011 Free Software Foundation, Inc.
388 +//
389 +// This file is part of the GNU ISO C++ Library.  This library is free
390 +// software; you can redistribute it and/or modify it under the
391 +// terms of the GNU General Public License as published by the
392 +// Free Software Foundation; either version 2, or (at your option)
393 +// any later version.
394 +//
395 +// This library is distributed in the hope that it will be useful,
396 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
397 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
398 +// GNU General Public License for more details.
399 +//
400 +// You should have received a copy of the GNU General Public License along
401 +// with this library; see the file COPYING.  If not, write to the Free
402 +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
403 +// USA.
404 +
405 +// 20.6.4 function object return types [func.ret]
406 +#include <functional>
407 +
408 +struct X
409 +{
410 +    int f(int) { return 0; }
411 +    int i;
412 +};
413 +
414 +void test01()
415 +{
416 +  typedef int (X::*mfp)(int);
417 +  typedef int X::*mp;
418 +  mfp m = &X::f;
419 +  mp m2 = &X::i;
420 +  X x = { };
421 +  std::ref(m)(x, 1);
422 +  std::ref(m)(&x, 1);
423 +  int& i1 = std::ref(m2)(x);
424 +  int& i2 = std::ref(m2)(&x);
425 +}
426 +
427 +int main()
428 +{
429 +  test01();
430 +  return 0;
431 +}
432 diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
433 index b371f1c..7b694c7 100644
434 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
435 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
436 @@ -1,6 +1,6 @@
437  // { dg-options "-std=gnu++0x" }
438  
439 -// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
440 +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
441  //
442  // This file is part of the GNU ISO C++ Library.  This library is free
443  // software; you can redistribute it and/or modify it under the
444 @@ -36,6 +36,7 @@ struct X
445    int foo_c(float x)  const          { return truncate_float(x); }
446    int foo_v(float x)  volatile       { return truncate_float(x); }
447    int foo_cv(float x) const volatile { return truncate_float(x); }
448 +  int foo_varargs(float x, ...)      { return truncate_float(x); }
449  
450    int operator()(float x)
451    {
452 @@ -69,6 +70,13 @@ void test01()
453  
454    ::get_seventeen get_sev;
455    ::X x;
456 +  ::X* xp = &x;
457 +  int (::X::* p_foo)(float) = &::X::foo;
458 +  int (::X::* p_foo_c)(float) const = &::X::foo_c;
459 +  int (::X::* p_foo_v)(float) volatile = &::X::foo_v;
460 +  int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv;
461 +  int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs;
462 +  int ::X::* p_bar = &::X::bar;
463  
464    const float pi = 3.14;
465  
466 @@ -77,8 +85,26 @@ void test01()
467    VERIFY(ref(seventeen)() == 17);
468  
469    // Function pointers
470 -  VERIFY(cref(&truncate_float)(pi) == 3);
471 -  VERIFY(cref(&seventeen)() == 17);
472 +  VERIFY(cref(truncate_float)(pi) == 3);
473 +  VERIFY(cref(seventeen)() == 17);
474 +
475 +  // Member function pointers
476 +  VERIFY(ref(p_foo)(x, pi) == 3);
477 +  VERIFY(ref(p_foo)(xp, pi) == 3);
478 +  VERIFY(ref(p_foo_c)(x, pi) == 3);
479 +  VERIFY(ref(p_foo_c)(xp, pi) == 3);
480 +  VERIFY(ref(p_foo_v)(x, pi) == 3);
481 +  VERIFY(ref(p_foo_v)(xp, pi) == 3);
482 +  VERIFY(ref(p_foo_cv)(x, pi) == 3);
483 +  VERIFY(ref(p_foo_cv)(xp, pi) == 3);
484 +  // VERIFY(ref(p_foo_varargs)(x, pi) == 3);
485 +  // VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3);
486 +  // VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3);
487 +  // VERIFY(ref(p_foo_varargs)(xp, pi) == 3);
488 +
489 +  // Member data pointers
490 +  VERIFY(ref(p_bar)(x) == 17);
491 +  VERIFY(ref(p_bar)(xp) == 17);
492  
493    // Function objects
494    VERIFY(ref(get_sev)() == 17);
495 diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc
496 new file mode 100644
497 index 0000000..947a9b0
498 --- /dev/null
499 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc
500 @@ -0,0 +1,44 @@
501 +// Copyright (C) 2011 Free Software Foundation, Inc.
502 +//
503 +// This file is part of the GNU ISO C++ Library.  This library is free
504 +// software; you can redistribute it and/or modify it under the
505 +// terms of the GNU General Public License as published by the
506 +// Free Software Foundation; either version 3, or (at your option)
507 +// any later version.
508 +
509 +// This library is distributed in the hope that it will be useful,
510 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
511 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
512 +// GNU General Public License for more details.
513 +
514 +// You should have received a copy of the GNU General Public License along
515 +// with this library; see the file COPYING3.  If not see
516 +// <http://www.gnu.org/licenses/>.
517 +
518 +// 20.8.3 Class template reference_wrapper
519 +
520 +// { dg-do compile }
521 +// { dg-options "-std=gnu++0x" }
522 +
523 +#include <functional>
524 +
525 +struct X { };
526 +X rval();
527 +X&& rvalref();
528 +
529 +void test01()
530 +{
531 +  std::ref(1);          // { dg-error "deleted" }
532 +  std::cref(1);         // { dg-error "deleted" }
533 +  std::ref( int() );    // { dg-error "deleted" }
534 +  std::cref( int() );   // { dg-error "deleted" }
535 +  std::ref(rval());     // { dg-error "deleted" }
536 +  std::cref(rvalref()); // { dg-error "deleted" }
537 +}
538 +
539 +int main()
540 +{
541 +  test02();
542 +}
543 +
544 +// { dg-excess-errors "" }
545 diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
546 new file mode 100644
547 index 0000000..2fea52e
548 --- /dev/null
549 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
550 @@ -0,0 +1,148 @@
551 +// { dg-options "-std=gnu++0x" }
552 +// { dg-do compile }
553 +
554 +// Copyright (C) 2011 Free Software Foundation, Inc.
555 +//
556 +// This file is part of the GNU ISO C++ Library.  This library is free
557 +// software; you can redistribute it and/or modify it under the
558 +// terms of the GNU General Public License as published by the
559 +// Free Software Foundation; either version 3, or (at your option)
560 +// any later version.
561 +//
562 +// This library is distributed in the hope that it will be useful,
563 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
564 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
565 +// GNU General Public License for more details.
566 +//
567 +// You should have received a copy of the GNU General Public License along
568 +// with this library; see the file COPYING3.  If not see
569 +// <http://www.gnu.org/licenses/>.
570 +
571 +#include <functional>
572 +#include <type_traits>
573 +
574 +struct S { };
575 +
576 +struct S0
577 +{
578 +  typedef int argument_type;
579 +};
580 +
581 +struct S1
582 +{
583 +  typedef float first_argument_type;
584 +};
585 +
586 +struct S2
587 +{
588 +  typedef char second_argument_type;
589 +};
590 +
591 +struct S01 : S0, S1 { };
592 +struct S02 : S0, S2 { };
593 +struct S12 : S1, S2 { };
594 +
595 +struct S012 : S0, S1, S2 { };
596 +
597 +using std::__sfinae_types;
598 +using std::integral_constant;
599 +using std::remove_cv;
600 +
601 +_GLIBCXX_HAS_NESTED_TYPE(argument_type)
602 +_GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
603 +_GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
604 +
605 +template<typename T>
606 +  struct has_arg_type : __has_argument_type<T>
607 +  { };
608 +
609 +template<typename T>
610 +  struct has_1st_arg_type : __has_first_argument_type<T>
611 +  { };
612 +
613 +template<typename T>
614 +  struct has_2nd_arg_type : __has_second_argument_type<T>
615 +  { };
616 +
617 +template<typename T, bool = has_arg_type<T>::value>
618 +struct test_arg_type
619 +{
620 +  static_assert( !has_arg_type<std::reference_wrapper<T>>::value,
621 +      "reference_wrapper has no nested argument_type");
622 +};
623 +
624 +template<typename T>
625 +struct test_arg_type<T, true>
626 +{
627 +  typedef std::reference_wrapper<T> ref;
628 +
629 +  static_assert( has_arg_type<ref>::value,
630 +      "reference_wrapper has nested argument_type");
631 +
632 +  static_assert(
633 +      std::is_same< typename T::argument_type,
634 +                    typename ref::argument_type >::value,
635 +      "reference_wrapper has the correct argument_type");
636 +};
637 +
638 +template<typename T,
639 +         bool = has_1st_arg_type<T>::value && has_2nd_arg_type<T>::value>
640 +struct test_1st_2nd_arg_types
641 +{
642 +  typedef std::reference_wrapper<T> ref;
643 +
644 +  static_assert( !has_1st_arg_type<ref>::value,
645 +      "reference_wrapper has no nested first_argument_type");
646 +
647 +  static_assert( !has_2nd_arg_type<ref>::value,
648 +      "reference_wrapper has no nested second_argument_type");
649 +};
650 +
651 +template<typename T>
652 +struct test_1st_2nd_arg_types<T, true>
653 +{
654 +  typedef std::reference_wrapper<T> ref;
655 +
656 +  static_assert( has_1st_arg_type<ref>::value,
657 +      "reference_wrapper has nested first_argument_type");
658 +
659 +  static_assert( has_2nd_arg_type<ref>::value,
660 +      "reference_wrapper has nested second_argument_type");
661 +
662 +  static_assert(
663 +      std::is_same< typename T::first_argument_type,
664 +                    typename ref::first_argument_type>::value,
665 +      "reference_wrapper has correct first_argument_type");
666 +
667 +  static_assert(
668 +      std::is_same< typename T::second_argument_type,
669 +                    typename ref::second_argument_type>::value,
670 +      "reference_wrapper has correct second_argument_type");
671 +};
672 +
673 +
674 +template<typename T>
675 +  void test()
676 +  {
677 +    test_arg_type<T> t;
678 +    test_arg_type<const T> tc;
679 +    test_arg_type<volatile T> tv;
680 +    test_arg_type<const volatile T> tcv;
681 +    test_1st_2nd_arg_types<T> t12;
682 +    test_1st_2nd_arg_types<const T> t12c;
683 +    test_1st_2nd_arg_types<volatile T> t12v;
684 +    test_1st_2nd_arg_types<const volatile T> t12cv;
685 +  }
686 +
687 +int main()
688 +{
689 +  test<S>();
690 +  test<S0>();
691 +  test<S1>();
692 +  test<S2>();
693 +  test<S01>();
694 +  test<S02>();
695 +  test<S12>();
696 +  test<S012>();
697 +}
698 +
699 diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
700 index 56ee29e..815700f 100644
701 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
702 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
703 @@ -1,6 +1,7 @@
704 +// { dg-do compile }
705  // { dg-options "-std=gnu++0x" }
706  
707 -// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
708 +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
709  //
710  // This file is part of the GNU ISO C++ Library.  This library is free
711  // software; you can redistribute it and/or modify it under the
712 @@ -19,10 +20,6 @@
713  
714  #include <functional>
715  #include <type_traits>
716 -#include <testsuite_hooks.h>
717 -#include <testsuite_tr1.h>
718 -
719 -using namespace __gnu_test;
720  
721  struct X {};
722  
723 @@ -41,43 +38,18 @@ struct derives_unary_binary
724  
725  void test01()
726  {
727 -  bool test __attribute__((unused)) = true;
728 -
729    using std::reference_wrapper;
730    using std::is_same;
731 -  using std::is_convertible;
732 -  using std::unary_function;
733 -  using std::binary_function;
734  
735    // Check result_type typedef
736 -  VERIFY((is_same<reference_wrapper<int_result_type>::result_type, int>::value));
737 -  VERIFY((is_same<reference_wrapper<derives_unary>::result_type, int>::value));
738 -  VERIFY((is_same<reference_wrapper<derives_binary>::result_type, int>::value));
739 -  VERIFY((is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value));
740 -  VERIFY((is_same<reference_wrapper<int(void)>::result_type, int>::value));
741 -  VERIFY((is_same<reference_wrapper<int(*)(void)>::result_type, int>::value));
742 -  VERIFY((is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value));
743 -  VERIFY((is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value));
744 -
745 -  // Check derivation from unary_function
746 -  VERIFY((is_convertible<reference_wrapper<derives_unary>*, unary_function<int, int>*>::value));
747 -  VERIFY((is_convertible<reference_wrapper<derives_unary_binary>*, unary_function<int, int>*>::value));
748 -  VERIFY((is_convertible<reference_wrapper<int(int)>*, unary_function<int, int>*>::value));
749 -  VERIFY((is_convertible<reference_wrapper<int(*)(int)>*, unary_function<int, int>*>::value));
750 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)()>*, unary_function< ::X*, int>*>::value));
751 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)() const>*, unary_function<const ::X*, int>*>::value));
752 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)() volatile>*, unary_function<volatile ::X*, int>*>::value));
753 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)() const volatile>*, unary_function<const volatile ::X*, int>*>::value));
754 -
755 -  // Check derivation from binary_function
756 -  VERIFY((is_convertible<reference_wrapper<derives_binary>*, binary_function<int, float, int>*>::value));
757 -  VERIFY((is_convertible<reference_wrapper<derives_unary_binary>*, binary_function<int, float, int>*>::value));
758 -  VERIFY((is_convertible<reference_wrapper<int(int, float)>*, binary_function<int, float, int>*>::value));
759 -  VERIFY((is_convertible<reference_wrapper<int(*)(int, float)>*, binary_function<int, float, int>*>::value));
760 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float)>*, binary_function< ::X*, float, int>*>::value));
761 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) const>*, binary_function<const ::X*, float, int>*>::value));
762 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) volatile>*, binary_function<volatile ::X*, float, int>*>::value));
763 -  VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) const volatile>*, binary_function<const volatile ::X*, float, int>*>::value));
764 +  static_assert( is_same<reference_wrapper<int_result_type>::result_type, int>::value, "has result_type" );
765 +  static_assert( is_same<reference_wrapper<derives_unary>::result_type, int>::value, "has result_type" );
766 +  static_assert( is_same<reference_wrapper<derives_binary>::result_type, int>::value, "has result_type" );
767 +  static_assert( is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value, "has result_type" );
768 +  static_assert( is_same<reference_wrapper<int(void)>::result_type, int>::value, "has result_type" );
769 +  static_assert( is_same<reference_wrapper<int(*)(void)>::result_type, int>::value, "has result_type" );
770 +  static_assert( is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value, "has result_type" );
771 +  static_assert( is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value, "has result_type" );
772  }
773  
774  int main()
775 -- 
776 1.7.0.4
777