OSDN Git Service

PR libstdc++/38017
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 20_util / reference_wrapper / 24803.cc
1 // { dg-options "-std=gnu++0x" }
2 // { dg-do compile }
3
4 // Copyright (C) 2008 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 2, 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 COPYING.  If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
21
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30
31 #include <functional>
32
33 struct test_type
34 {
35    int member();
36    int cmember()const;
37    int member2(char);
38    int cmember2(char)const;
39 };
40
41 struct functor1 : public std::unary_function<int, double>
42 {
43   double operator()(int) const;
44 };
45
46 struct functor2 : public std::binary_function<int, char, double>
47 {
48    double operator()(int, char) const;
49 };
50
51 template <class T>
52 void verify_return_type(T, T)
53 {
54 }
55
56 void test01()
57 {
58    test_type* null_tt = 0;
59    const test_type* null_ttc = 0;
60    int zero;
61
62    std::reference_wrapper<double (int)>* pr1(0);
63    verify_return_type((*pr1)(0), double());
64    std::reference_wrapper<double (*)(int)>* pr2(0);
65    verify_return_type((*pr2)(0), double());
66    std::reference_wrapper<int (test_type::*)()>* pr3(0);
67    verify_return_type((*pr3)(null_tt), int());
68    std::reference_wrapper<int (test_type::*)()const>* pr4(0);
69    verify_return_type((*pr4)(null_ttc), int());
70    std::reference_wrapper<functor1>* pr5(0);
71
72    // libstdc++/24803
73    // FIXME: verify_return_type((*pr5)(0), double());
74    verify_return_type((*pr5)(zero), double());
75
76    std::reference_wrapper<double (int, char)>* pr1b(0);
77    verify_return_type((*pr1b)(0,0), double());
78    std::reference_wrapper<double (*)(int, char)>* pr2b(0);
79    verify_return_type((*pr2b)(0,0), double());
80    std::reference_wrapper<int (test_type::*)(char)>* pr3b(0);
81    verify_return_type((*pr3b)(null_tt,zero), int());
82    std::reference_wrapper<int (test_type::*)()const>* pr4b(0);
83    verify_return_type((*pr4b)(null_ttc), int());
84    std::reference_wrapper<functor2>* pr5b(0);
85
86    // libstdc++/24803
87    // FIXME: verify_return_type((*pr5b)(0,0), double());
88    verify_return_type((*pr5b)(zero,zero), double());
89 }