]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do compile { target c++11 } } |
7a90b0ca | 2 | |
99dee823 | 3 | // Copyright (C) 2008-2021 Free Software Foundation, Inc. |
7a90b0ca PC |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
7a90b0ca PC |
9 | // any later version. |
10 | // | |
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
7a90b0ca | 19 | |
7a90b0ca PC |
20 | |
21 | #include <functional> | |
22 | ||
23 | struct test_type | |
24 | { | |
25 | int member(); | |
26 | int cmember()const; | |
27 | int member2(char); | |
28 | int cmember2(char)const; | |
29 | }; | |
30 | ||
31 | struct functor1 : public std::unary_function<int, double> | |
32 | { | |
33 | double operator()(int) const; | |
34 | }; | |
35 | ||
36 | struct functor2 : public std::binary_function<int, char, double> | |
37 | { | |
38 | double operator()(int, char) const; | |
39 | }; | |
40 | ||
41 | template <class T> | |
42 | void verify_return_type(T, T) | |
43 | { | |
44 | } | |
45 | ||
46 | void test01() | |
47 | { | |
be7f7822 JW |
48 | test_type* null_tt = 0; |
49 | const test_type* null_ttc = 0; | |
315a716e | 50 | int zero; |
7a90b0ca | 51 | |
315a716e PC |
52 | std::reference_wrapper<double (int)>* pr1(0); |
53 | verify_return_type((*pr1)(0), double()); | |
54 | std::reference_wrapper<double (*)(int)>* pr2(0); | |
55 | verify_return_type((*pr2)(0), double()); | |
be7f7822 JW |
56 | std::reference_wrapper<int (test_type::*)()>* pr3(0); |
57 | verify_return_type((*pr3)(null_tt), int()); | |
58 | std::reference_wrapper<int (test_type::*)()const>* pr4(0); | |
59 | verify_return_type((*pr4)(null_ttc), int()); | |
315a716e | 60 | std::reference_wrapper<functor1>* pr5(0); |
7a90b0ca | 61 | |
315a716e PC |
62 | // libstdc++/24803 |
63 | verify_return_type((*pr5)(0), double()); | |
64 | verify_return_type((*pr5)(zero), double()); | |
7a90b0ca | 65 | |
315a716e PC |
66 | std::reference_wrapper<double (int, char)>* pr1b(0); |
67 | verify_return_type((*pr1b)(0, 0), double()); | |
68 | std::reference_wrapper<double (*)(int, char)>* pr2b(0); | |
69 | verify_return_type((*pr2b)(0, 0), double()); | |
be7f7822 JW |
70 | std::reference_wrapper<int (test_type::*)(char)>* pr3b(0); |
71 | verify_return_type((*pr3b)(null_tt,zero), int()); | |
72 | std::reference_wrapper<int (test_type::*)()const>* pr4b(0); | |
73 | verify_return_type((*pr4b)(null_ttc), int()); | |
315a716e | 74 | std::reference_wrapper<functor2>* pr5b(0); |
7a90b0ca | 75 | |
315a716e PC |
76 | // libstdc++/24803 |
77 | verify_return_type((*pr5b)(0, 0), double()); | |
78 | verify_return_type((*pr5b)(zero, zero), double()); | |
7a90b0ca | 79 | } |