Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.perf / template-breakpoints.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright (C) 2018-2020 Free Software Foundation, Inc.
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 #include <iostream>
19
20 template <int I, int J, int K, int VAL>
21 struct ThirdDimension
22 {
23 int
24 value () const
25 {
26 ThirdDimension<I, J, K - 1, VAL> d3;
27 return d3.value();
28 }
29 };
30
31 template <int I, int J, int VAL>
32 struct ThirdDimension<I, J, 0, VAL>
33 {
34 int
35 value () const
36 {
37 // Please note - this testcase sets a breakpoint on the following line.
38 // It is therefore sensitive to line numbers. If any changes are made to
39 // this file, please ensure that the testcase is updated to reflect this.
40 std::cout << "Value: " << VAL << std::endl;
41 return VAL;
42 }
43 };
44
45 template <int I, int J, int K, int VAL>
46 struct SecondDimension
47 {
48 int
49 value () const
50 {
51 SecondDimension<I, J - 1, K, VAL> d1;
52 ThirdDimension<I, J, K, VAL> d2;
53 return d1.value() + d2.value();
54 }
55 };
56
57 template <int I, int K, int VAL>
58 struct SecondDimension<I, 0, K, VAL>
59 {
60 int
61 value () const
62 {
63 ThirdDimension<I, 0, K, VAL> d2;
64 return d2.value();
65 }
66 };
67
68 template <int I, int J, int K, int VAL>
69 struct FirstDimension
70 {
71 int
72 value () const
73 {
74 FirstDimension<I - 1, J, K, VAL> d1;
75 SecondDimension<I, J, K, VAL> d2;
76 return d1.value() + d2.value();
77 }
78 };
79
80 template <int J, int K, int VAL>
81 struct FirstDimension<0, J, K, VAL>
82 {
83 int
84 value () const
85 {
86 SecondDimension<0, J, K, VAL> d2;
87 return d2.value();
88 }
89 };
90
91 int
92 main (int argc, char *argv[])
93 {
94 FirstDimension<EXPANSION_DEPTH, EXPANSION_DEPTH, EXPANSION_DEPTH, 1> product;
95 std::cout << product.value() << std::endl;
96 return 0;
97 }
This page took 0.031027 seconds and 4 git commands to generate.