]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 26_numerics / headers / numeric / synopsis.cc
1 // { dg-do compile }
2
3 // Copyright (C) 2007-2021 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 3, or (at your option)
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
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 #include <numeric>
21
22 #if __cplusplus > 201703L
23 #define CONSTEXPR constexpr
24 #else
25 #define CONSTEXPR
26 #endif
27
28 namespace std {
29 template <class InputIterator, class T>
30 CONSTEXPR
31 T accumulate(InputIterator first, InputIterator last, T init);
32
33 template <class InputIterator, class T, class BinaryOperation>
34 CONSTEXPR
35 T accumulate(InputIterator first, InputIterator last, T init,
36 BinaryOperation binary_op);
37
38 template <class InputIterator1, class InputIterator2, class T>
39 CONSTEXPR
40 T inner_product(InputIterator1 first1, InputIterator1 last1,
41 InputIterator2 first2, T init);
42
43 template <class InputIterator1, class InputIterator2, class T,
44 class BinaryOperation1, class BinaryOperation2>
45 CONSTEXPR
46 T inner_product(InputIterator1 first1, InputIterator1 last1,
47 InputIterator2 first2, T init,
48 BinaryOperation1 binary_op1,
49 BinaryOperation2 binary_op2);
50
51 template <class InputIterator, class OutputIterator>
52 CONSTEXPR
53 OutputIterator partial_sum(InputIterator first,
54 InputIterator last,
55 OutputIterator result);
56
57 template <class InputIterator, class OutputIterator,
58 class BinaryOperation>
59 CONSTEXPR
60 OutputIterator partial_sum(InputIterator first,
61 InputIterator last,
62 OutputIterator result,
63 BinaryOperation binary_op);
64
65 template <class InputIterator, class OutputIterator>
66 CONSTEXPR
67 OutputIterator adjacent_difference(InputIterator first,
68 InputIterator last,
69 OutputIterator result);
70
71 template <class InputIterator, class OutputIterator,
72 class BinaryOperation>
73 CONSTEXPR
74 OutputIterator adjacent_difference(InputIterator first,
75 InputIterator last,
76 OutputIterator result,
77 BinaryOperation binary_op);
78 #if __cplusplus >= 201103L
79 template<class ForwardIterator, class T>
80 CONSTEXPR void iota(ForwardIterator first, ForwardIterator last, T value);
81 #endif // C++11
82
83 #if __cplusplus >= 201703L
84 template<class InputIterator>
85 CONSTEXPR typename iterator_traits<InputIterator>::value_type
86 reduce(InputIterator first, InputIterator last);
87
88 template<class InputIterator, class T>
89 CONSTEXPR T reduce(InputIterator first, InputIterator last, T init);
90
91 template<class InputIterator, class T, class BinaryOperation>
92 CONSTEXPR T reduce(InputIterator first, InputIterator last, T init,
93 BinaryOperation binary_op);
94
95 template<class InputIterator, class OutputIterator, class T>
96 CONSTEXPR OutputIterator
97 exclusive_scan(InputIterator first, InputIterator last,
98 OutputIterator result, T init);
99
100 template<class InputIterator, class OutputIterator, class T,
101 class BinaryOperation>
102 CONSTEXPR OutputIterator
103 exclusive_scan(InputIterator first, InputIterator last,
104 OutputIterator result, T init, BinaryOperation binary_op);
105
106 template<class InputIterator, class OutputIterator>
107 CONSTEXPR OutputIterator
108 inclusive_scan(InputIterator first, InputIterator last,
109 OutputIterator result);
110
111 template<class InputIterator, class OutputIterator, class BinaryOperation>
112 CONSTEXPR OutputIterator
113 inclusive_scan(InputIterator first, InputIterator last,
114 OutputIterator result, BinaryOperation binary_op);
115
116 template<class InputIterator, class OutputIterator, class BinaryOperation,
117 class T>
118 CONSTEXPR OutputIterator
119 inclusive_scan(InputIterator first, InputIterator last,
120 OutputIterator result, BinaryOperation binary_op, T init);
121
122 template<class InputIterator1, class InputIterator2, class T>
123 CONSTEXPR T transform_reduce(InputIterator1 first1, InputIterator1 last1,
124 InputIterator2 first2, T init);
125
126 template<class InputIterator1, class InputIterator2, class T,
127 class BinaryOperation1, class BinaryOperation2>
128 CONSTEXPR T transform_reduce(InputIterator1 first1, InputIterator1 last1,
129 InputIterator2 first2, T init,
130 BinaryOperation1 binary_op1,
131 BinaryOperation2 binary_op2);
132
133 template<class InputIterator, class T,
134 class BinaryOperation, class UnaryOperation>
135 CONSTEXPR T transform_reduce(InputIterator first, InputIterator last, T init,
136 BinaryOperation binary_op,
137 UnaryOperation unary_op);
138
139 template<class InputIterator, class OutputIterator, class T,
140 class BinaryOperation, class UnaryOperation>
141 CONSTEXPR OutputIterator
142 transform_exclusive_scan(InputIterator first, InputIterator last,
143 OutputIterator result, T init,
144 BinaryOperation binary_op, UnaryOperation unary_op);
145
146 template<class InputIterator, class OutputIterator,
147 class BinaryOperation, class UnaryOperation>
148 CONSTEXPR OutputIterator
149 transform_inclusive_scan(InputIterator first, InputIterator last,
150 OutputIterator result,
151 BinaryOperation binary_op, UnaryOperation unary_op);
152
153 template<class InputIterator, class OutputIterator,
154 class BinaryOperation, class UnaryOperation, class T>
155 CONSTEXPR OutputIterator
156 transform_inclusive_scan(InputIterator first, InputIterator last,
157 OutputIterator result,
158 BinaryOperation binary_op, UnaryOperation unary_op,
159 T init);
160 #endif // C++17
161
162 #if __cplusplus > 201703L
163 template<class M, class N>
164 constexpr common_type_t<M,N> gcd(M m, N n);
165
166 template<class M, class N>
167 constexpr common_type_t<M,N> lcm(M m, N n);
168
169 template<class T>
170 constexpr T midpoint(T a, T b) noexcept;
171
172 template<class T>
173 constexpr T* midpoint(T* a, T* b);
174 #endif // C++2a
175 }