]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / reference_wrapper / 24803.cc
CommitLineData
8868286e 1// { dg-options "-std=gnu++11" }
146ac79f 2// { dg-do compile }
3
f1717362 4// Copyright (C) 2008-2016 Free Software Foundation, Inc.
146ac79f 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
6bc9506f 9// Free Software Foundation; either version 3, or (at your option)
146ac79f 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
6bc9506f 18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
146ac79f 20
146ac79f 21
22#include <functional>
23
24struct test_type
25{
26 int member();
27 int cmember()const;
28 int member2(char);
29 int cmember2(char)const;
30};
31
32struct functor1 : public std::unary_function<int, double>
33{
34 double operator()(int) const;
35};
36
37struct functor2 : public std::binary_function<int, char, double>
38{
39 double operator()(int, char) const;
40};
41
42template <class T>
43void verify_return_type(T, T)
44{
45}
46
47void test01()
48{
409e2405 49 test_type* null_tt = 0;
50 const test_type* null_ttc = 0;
a0a0ff44 51 int zero;
146ac79f 52
a0a0ff44 53 std::reference_wrapper<double (int)>* pr1(0);
54 verify_return_type((*pr1)(0), double());
55 std::reference_wrapper<double (*)(int)>* pr2(0);
56 verify_return_type((*pr2)(0), double());
409e2405 57 std::reference_wrapper<int (test_type::*)()>* pr3(0);
58 verify_return_type((*pr3)(null_tt), int());
59 std::reference_wrapper<int (test_type::*)()const>* pr4(0);
60 verify_return_type((*pr4)(null_ttc), int());
a0a0ff44 61 std::reference_wrapper<functor1>* pr5(0);
146ac79f 62
a0a0ff44 63 // libstdc++/24803
64 verify_return_type((*pr5)(0), double());
65 verify_return_type((*pr5)(zero), double());
146ac79f 66
a0a0ff44 67 std::reference_wrapper<double (int, char)>* pr1b(0);
68 verify_return_type((*pr1b)(0, 0), double());
69 std::reference_wrapper<double (*)(int, char)>* pr2b(0);
70 verify_return_type((*pr2b)(0, 0), double());
409e2405 71 std::reference_wrapper<int (test_type::*)(char)>* pr3b(0);
72 verify_return_type((*pr3b)(null_tt,zero), int());
73 std::reference_wrapper<int (test_type::*)()const>* pr4b(0);
74 verify_return_type((*pr4b)(null_ttc), int());
a0a0ff44 75 std::reference_wrapper<functor2>* pr5b(0);
146ac79f 76
a0a0ff44 77 // libstdc++/24803
78 verify_return_type((*pr5b)(0, 0), double());
79 verify_return_type((*pr5b)(zero, zero), double());
146ac79f 80}