summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/reference_wrapper
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/20_util/reference_wrapper
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/reference_wrapper')
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc80
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc34
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc46
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc120
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc44
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc42
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc69
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc148
-rw-r--r--libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc59
9 files changed, 642 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
new file mode 100644
index 000000000..4bf61485c
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
@@ -0,0 +1,80 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 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
+// 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>
+
+struct test_type
+{
+ int member();
+ int cmember()const;
+ int member2(char);
+ int cmember2(char)const;
+};
+
+struct functor1 : public std::unary_function<int, double>
+{
+ double operator()(int) const;
+};
+
+struct functor2 : public std::binary_function<int, char, double>
+{
+ double operator()(int, char) const;
+};
+
+template <class T>
+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
+ verify_return_type((*pr5)(0), double());
+ verify_return_type((*pr5)(zero), double());
+
+ std::reference_wrapper<double (int, char)>* pr1b(0);
+ 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
+ verify_return_type((*pr5b)(0, 0), double());
+ verify_return_type((*pr5b)(zero, zero), double());
+}
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc
new file mode 100644
index 000000000..b167d7122
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+// libstdc++/41792
+void test01()
+{
+ using namespace __gnu_test;
+
+ OverloadedAddress* ao1 = new OverloadedAddress();
+ std::reference_wrapper<OverloadedAddress> rw1(*ao1);
+}
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 000000000..c1b62932f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc
@@ -0,0 +1,46 @@
+// { 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/>.
+
+// 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
new file mode 100644
index 000000000..7b694c764
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
@@ -0,0 +1,120 @@
+// { dg-options "-std=gnu++0x" }
+
+// 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
+// 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>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+
+bool test __attribute__((unused)) = true;
+
+struct X
+{
+ typedef int result_type;
+
+ X() : bar(17) {}
+
+ int foo(float x) { return truncate_float(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)
+ {
+ return foo(x) + 1;
+ }
+
+ int operator()(float x) const
+ {
+ return foo_c(x) + 2;
+ }
+
+ int bar;
+
+ private:
+ X(const X&);
+ X& operator=(const X&);
+};
+
+int seventeen() { return 17; }
+
+struct get_seventeen
+{
+ typedef int result_type;
+ int operator()() const { return 17; }
+};
+
+void test01()
+{
+ using std::ref;
+ using std::cref;
+
+ ::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;
+
+ // Functions
+ VERIFY(ref(truncate_float)(pi) == 3);
+ VERIFY(ref(seventeen)() == 17);
+
+ // Function pointers
+ 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);
+ VERIFY(cref(get_sev)() == 17);
+ VERIFY(ref(x)(pi) == 4);
+ VERIFY(cref(x)(pi) == 5);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
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 000000000..947a9b02f
--- /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/result_type.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc
new file mode 100644
index 000000000..911e9a944
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-10-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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>
+
+using namespace std;
+
+struct T;
+
+reference_wrapper<int(float, ...)>::result_type i01;
+reference_wrapper<int(float, ...) const>::result_type i02;
+reference_wrapper<int(float, ...) volatile>::result_type i03;
+reference_wrapper<int(float, ...) const volatile>::result_type i04;
+
+reference_wrapper<int(*)(float, ...)>::result_type i05;
+reference_wrapper<int(* const)(float, ...)>::result_type i06;
+reference_wrapper<int(* volatile)(float, ...)>::result_type i07;
+reference_wrapper<int(* const volatile)(float, ...)>::result_type i08;
+
+reference_wrapper<int(T::*)(float, ...)>::result_type i09;
+reference_wrapper<int(T::*)(float, ...) const>::result_type i10;
+reference_wrapper<int(T::*)(float, ...) volatile>::result_type i11;
+reference_wrapper<int(T::*)(float, ...) const volatile>::result_type i12;
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc
new file mode 100644
index 000000000..8b1b7e3f1
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc
@@ -0,0 +1,69 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-10-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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>
+
+using namespace std;
+
+reference_wrapper<int(float)>::argument_type i01;
+reference_wrapper<int(float) const>::argument_type i02;
+reference_wrapper<int(float) volatile>::argument_type i03;
+reference_wrapper<int(float) const volatile>::argument_type i04;
+reference_wrapper<int(float)>::result_type i05;
+reference_wrapper<int(float) const>::result_type i06;
+reference_wrapper<int(float) volatile>::result_type i07;
+reference_wrapper<int(float) const volatile>::result_type i08;
+
+reference_wrapper<int(*)(float)>::argument_type i09;
+reference_wrapper<int(* const)(float)>::argument_type i10;
+reference_wrapper<int(* volatile)(float)>::argument_type i11;
+reference_wrapper<int(* const volatile)(float)>::argument_type i12;
+reference_wrapper<int(*)(float)>::result_type i13;
+reference_wrapper<int(* const)(float)>::result_type i14;
+reference_wrapper<int(* volatile)(float)>::result_type i15;
+reference_wrapper<int(* const volatile)(float)>::result_type i16;
+
+reference_wrapper<int(float, char)>::first_argument_type i17;
+reference_wrapper<int(float, char) const>::first_argument_type i18;
+reference_wrapper<int(float, char) volatile>::first_argument_type i19;
+reference_wrapper<int(float, char) const volatile>::first_argument_type i20;
+reference_wrapper<int(float, char)>::second_argument_type i21;
+reference_wrapper<int(float, char) const>::second_argument_type i22;
+reference_wrapper<int(float, char) volatile>::second_argument_type i23;
+reference_wrapper<int(float, char) const volatile>::second_argument_type i24;
+reference_wrapper<int(float, char)>::result_type i25;
+reference_wrapper<int(float, char) const>::result_type i26;
+reference_wrapper<int(float, char) volatile>::result_type i27;
+reference_wrapper<int(float, char) const volatile>::result_type i28;
+
+reference_wrapper<int(*)(float, char)>::first_argument_type i29;
+reference_wrapper<int(* const)(float, char)>::first_argument_type i30;
+reference_wrapper<int(* volatile)(float, char)>::first_argument_type i31;
+reference_wrapper<int(* const volatile)(float, char)>::first_argument_type i32;
+reference_wrapper<int(*)(float, char)>::second_argument_type i33;
+reference_wrapper<int(* const)(float, char)>::second_argument_type i34;
+reference_wrapper<int(* volatile)(float, char)>::second_argument_type i35;
+reference_wrapper<int(*const volatile)(float, char)>::second_argument_type i36;
+reference_wrapper<int(*)(float, char)>::result_type i37;
+reference_wrapper<int(* const)(float, char)>::result_type i38;
+reference_wrapper<int(* volatile)(float, char)>::result_type i39;
+reference_wrapper<int(* const volatile)(float, char)>::result_type i40;
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 000000000..2fea52eed
--- /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
new file mode 100644
index 000000000..815700f1c
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc
@@ -0,0 +1,59 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 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
+// 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 X {};
+
+struct int_result_type { typedef int result_type; };
+
+struct derives_unary : std::unary_function<int, int> {};
+
+struct derives_binary : std::binary_function<int, float, int> {};
+
+struct derives_unary_binary
+ : std::unary_function<int, int>,
+ std::binary_function<int, float, int>
+{
+ typedef int result_type;
+};
+
+void test01()
+{
+ using std::reference_wrapper;
+ using std::is_same;
+
+ // Check result_type typedef
+ 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()
+{
+ test01();
+ return 0;
+}