Add "continue" response to pager
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / rvalue-ref-overload.cc
CommitLineData
c0f55cc6
AV
1/* This testcase is part of GDB, the GNU debugger.
2
e2882c85 3 Copyright 1998-2018 Free Software Foundation, Inc.
c0f55cc6
AV
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Rvalue references overload tests for GDB, based on overload.cc. */
19
20#include <stddef.h>
21#include <utility>
22
23class foo;
24
25typedef foo &foo_lval_ref;
26typedef foo &&foo_rval_ref;
27
28class foo
29{
30public:
31 foo ();
32 foo (foo_lval_ref);
33 foo (foo_rval_ref);
34 ~foo ();
35
36 int overload1arg (foo_lval_ref);
37 int overload1arg (foo_rval_ref);
38};
39
40void
41marker1 ()
42{
43}
44
45static int
46f (int &x)
47{
48 return 1;
49}
50
51static int
52f (const int &x)
53{
54 return 2;
55}
56
57static int
58f (int &&x)
59{
60 return 3;
61}
62
63int
64main ()
65{
66 foo foo_rr_instance1;
67 foo arg;
68 int i = 0;
69 const int ci = 0;
70
71 // result = 1 + 2 + 3 + 3 = 9
72 int result = f (i) + f (ci) + f (0) + f (std::move (i));
73
74 marker1 (); // marker1-returns-here
75 return result;
76}
77
78foo::foo () {}
79foo::foo (foo_lval_ref afoo) {}
80foo::foo (foo_rval_ref afoo) {}
81foo::~foo () {}
82
83/* Some functions to test overloading by varying one argument type. */
84
85int foo::overload1arg (foo_lval_ref arg) { return 1; }
86int foo::overload1arg (foo_rval_ref arg) { return 2; }
This page took 0.170271 seconds and 4 git commands to generate.