OSDN Git Service

2011-04-19 Jonathan Wakely <jwakely.gcc@gmail.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 20_util / reference_wrapper / typedefs.cc
1 // { dg-do compile }
2 // { dg-options "-std=gnu++0x" }
3
4 // Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3.  If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <functional>
22 #include <type_traits>
23
24 struct X {};
25
26 struct int_result_type { typedef int result_type; };
27
28 struct derives_unary : std::unary_function<int, int> {};
29
30 struct derives_binary : std::binary_function<int, float, int> {};
31
32 struct derives_unary_binary
33   : std::unary_function<int, int>,
34     std::binary_function<int, float, int>
35 {
36   typedef int result_type;
37 };
38
39 void test01()
40 {
41   using std::reference_wrapper;
42   using std::is_same;
43
44   // Check result_type typedef
45   static_assert( is_same<reference_wrapper<int_result_type>::result_type, int>::value, "has result_type" );
46   static_assert( is_same<reference_wrapper<derives_unary>::result_type, int>::value, "has result_type" );
47   static_assert( is_same<reference_wrapper<derives_binary>::result_type, int>::value, "has result_type" );
48   static_assert( is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value, "has result_type" );
49   static_assert( is_same<reference_wrapper<int(void)>::result_type, int>::value, "has result_type" );
50   static_assert( is_same<reference_wrapper<int(*)(void)>::result_type, int>::value, "has result_type" );
51   static_assert( is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value, "has result_type" );
52   static_assert( is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value, "has result_type" );
53 }
54
55 int main()
56 {
57   test01();
58   return 0;
59 }