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>
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
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.
28 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172901 138bc75d-0d04-0410-961f-82ee72b054a4
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;
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
44 - template<typename _Tp>
45 - struct _Function_to_function_pointer<_Tp, true>
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
60 __invoke(_Functor& __f, _Args&&... __args)
62 return __f(std::forward<_Args>(__args)...);
65 + template<typename _Functor, typename... _Args>
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
73 + __invoke(_Functor& __f, _Args&&... __args)
75 + return mem_fn(__f)(std::forward<_Args>(__args)...);
78 // To pick up function references (that will become function pointers)
79 template<typename _Functor, typename... _Args>
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
87 __invoke(_Functor __f, _Args&&... __args)
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;
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>
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>
107 + : _Weak_result_type<_Tp>
109 + typedef typename _Tp::argument_type argument_type;
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>
120 + : _Weak_result_type<_Tp>
122 + typedef typename _Tp::first_argument_type first_argument_type;
123 + typedef typename _Tp::second_argument_type second_argument_type;
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>
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;
144 + _GLIBCXX_HAS_NESTED_TYPE(argument_type)
145 + _GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
146 + _GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
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,
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>
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
177 @@ -456,7 +456,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
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
185 return __invoke(get(), std::forward<_Args>(__args)...);
186 @@ -476,6 +476,12 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
188 { return reference_wrapper<const _Tp>(__t); }
190 + template<typename _Tp>
191 + void ref(const _Tp&&) = delete;
193 + template<typename _Tp>
194 + void cref(const _Tp&&) = delete;
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);
207 + template<typename _FnCheck, typename _Fn, typename... _Args>
208 + struct __async_sfinae_helper
210 + typedef future<typename result_of<_Fn(_Args...)>::type> type;
213 + template<typename _Fn, typename... _Args>
214 + struct __async_sfinae_helper<launch, _Fn, _Args...>
217 template<typename _Fn, typename... _Args>
219 - enable_if<!is_same<typename decay<_Fn>::type, launch>::value,
220 - future<decltype(std::declval<_Fn>()(std::declval<_Args>()...))>
222 + __async_sfinae_helper<typename decay<_Fn>::type, _Fn, _Args...>::type
223 async(_Fn&& __fn, _Args&&... __args);
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>
230 - enable_if<!is_same<typename decay<_Fn>::type, launch>::value,
231 - future<decltype(std::declval<_Fn>()(std::declval<_Args>()...))>
233 + __async_sfinae_helper<typename decay<_Fn>::type, _Fn, _Args...>::type
234 async(_Fn&& __fn, _Args&&... __args)
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>
245 + template<typename _MemPtr, typename _Arg>
246 + struct _Result_of_memobj;
248 + template<typename _Res, typename _Class, typename _Arg>
249 + struct _Result_of_memobj<_Res _Class::*, _Arg>
252 + typedef _Res _Class::* _Func;
254 + template<typename _Tp>
255 + static _Tp _S_get(const _Class&);
256 + template<typename _Tp>
257 + static decltype(*std::declval<_Tp>()) _S_get(...);
261 + decltype(_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
265 + template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
266 + struct _Result_of_memfun;
268 + template<typename _Res, typename _Class, typename _Arg, typename... _Args>
269 + struct _Result_of_memfun<_Res _Class::*, _Arg, _Args...>
272 + typedef _Res _Class::* _Func;
274 + template<typename _Tp>
275 + static _Tp _S_get(const _Class&);
276 + template<typename _Tp>
277 + static decltype(*std::declval<_Tp>()) _S_get(...);
281 + decltype((_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
282 + (std::declval<_Args>()...) )
286 + template<bool, bool, typename _Functor, typename... _ArgTypes>
287 + struct _Result_of_impl;
289 template<typename _Functor, typename... _ArgTypes>
290 - struct result_of<_Functor(_ArgTypes...)>
291 + struct _Result_of_impl<false, false, _Functor, _ArgTypes...>
294 decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) )
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>
303 + typedef typename _Result_of_memobj<
304 + typename remove_reference<_MemPtr>::type, _Arg>::__type
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,
313 + typedef typename _Result_of_memfun<
314 + typename remove_reference<_MemPtr>::type, _Arg, _ArgTypes...>::__type
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...>
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
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
341 // { dg-options "-std=gnu++0x" }
344 -// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
345 +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
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)
353 + test_type* null_tt = 0;
354 + const test_type* null_ttc = 0;
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);
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);
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
381 index 0000000..bd9aeb2
383 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc
385 +// { dg-options "-std=gnu++0x" }
387 +// Copyright (C) 2011 Free Software Foundation, Inc.
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.
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.
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,
405 +// 20.6.4 function object return types [func.ret]
406 +#include <functional>
410 + int f(int) { return 0; }
416 + typedef int (X::*mfp)(int);
417 + typedef int X::*mp;
422 + std::ref(m)(&x, 1);
423 + int& i1 = std::ref(m2)(x);
424 + int& i2 = std::ref(m2)(&x);
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
437 // { dg-options "-std=gnu++0x" }
439 -// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
440 +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
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); }
450 int operator()(float x)
452 @@ -69,6 +70,13 @@ void test01()
454 ::get_seventeen get_sev;
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;
464 const float pi = 3.14;
466 @@ -77,8 +85,26 @@ void test01()
467 VERIFY(ref(seventeen)() == 17);
470 - VERIFY(cref(&truncate_float)(pi) == 3);
471 - VERIFY(cref(&seventeen)() == 17);
472 + VERIFY(cref(truncate_float)(pi) == 3);
473 + VERIFY(cref(seventeen)() == 17);
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);
489 + // Member data pointers
490 + VERIFY(ref(p_bar)(x) == 17);
491 + VERIFY(ref(p_bar)(xp) == 17);
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
497 index 0000000..947a9b0
499 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc
501 +// Copyright (C) 2011 Free Software Foundation, Inc.
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.
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.
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/>.
518 +// 20.8.3 Class template reference_wrapper
520 +// { dg-do compile }
521 +// { dg-options "-std=gnu++0x" }
523 +#include <functional>
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" }
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
547 index 0000000..2fea52e
549 +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
551 +// { dg-options "-std=gnu++0x" }
552 +// { dg-do compile }
554 +// Copyright (C) 2011 Free Software Foundation, Inc.
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.
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.
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/>.
571 +#include <functional>
572 +#include <type_traits>
578 + typedef int argument_type;
583 + typedef float first_argument_type;
588 + typedef char second_argument_type;
591 +struct S01 : S0, S1 { };
592 +struct S02 : S0, S2 { };
593 +struct S12 : S1, S2 { };
595 +struct S012 : S0, S1, S2 { };
597 +using std::__sfinae_types;
598 +using std::integral_constant;
599 +using std::remove_cv;
601 +_GLIBCXX_HAS_NESTED_TYPE(argument_type)
602 +_GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
603 +_GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
605 +template<typename T>
606 + struct has_arg_type : __has_argument_type<T>
609 +template<typename T>
610 + struct has_1st_arg_type : __has_first_argument_type<T>
613 +template<typename T>
614 + struct has_2nd_arg_type : __has_second_argument_type<T>
617 +template<typename T, bool = has_arg_type<T>::value>
618 +struct test_arg_type
620 + static_assert( !has_arg_type<std::reference_wrapper<T>>::value,
621 + "reference_wrapper has no nested argument_type");
624 +template<typename T>
625 +struct test_arg_type<T, true>
627 + typedef std::reference_wrapper<T> ref;
629 + static_assert( has_arg_type<ref>::value,
630 + "reference_wrapper has nested argument_type");
633 + std::is_same< typename T::argument_type,
634 + typename ref::argument_type >::value,
635 + "reference_wrapper has the correct argument_type");
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
642 + typedef std::reference_wrapper<T> ref;
644 + static_assert( !has_1st_arg_type<ref>::value,
645 + "reference_wrapper has no nested first_argument_type");
647 + static_assert( !has_2nd_arg_type<ref>::value,
648 + "reference_wrapper has no nested second_argument_type");
651 +template<typename T>
652 +struct test_1st_2nd_arg_types<T, true>
654 + typedef std::reference_wrapper<T> ref;
656 + static_assert( has_1st_arg_type<ref>::value,
657 + "reference_wrapper has nested first_argument_type");
659 + static_assert( has_2nd_arg_type<ref>::value,
660 + "reference_wrapper has nested second_argument_type");
663 + std::is_same< typename T::first_argument_type,
664 + typename ref::first_argument_type>::value,
665 + "reference_wrapper has correct first_argument_type");
668 + std::is_same< typename T::second_argument_type,
669 + typename ref::second_argument_type>::value,
670 + "reference_wrapper has correct second_argument_type");
674 +template<typename T>
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;
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
704 +// { dg-do compile }
705 // { dg-options "-std=gnu++0x" }
707 -// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
708 +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
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
714 #include <functional>
715 #include <type_traits>
716 -#include <testsuite_hooks.h>
717 -#include <testsuite_tr1.h>
719 -using namespace __gnu_test;
723 @@ -41,43 +38,18 @@ struct derives_unary_binary
727 - bool test __attribute__((unused)) = true;
729 using std::reference_wrapper;
731 - using std::is_convertible;
732 - using std::unary_function;
733 - using std::binary_function;
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));
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));
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" );