Skip to content

Commit 50d9c0c

Browse files
committed
Docs for aggregators
1 parent bfb3a0f commit 50d9c0c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

inc/aggregators.hpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ template <typename T, typename Fun> void foreach (generator<T> gen, Fun func) {
202202
}
203203
}
204204

205+
/**
206+
* \brief Sends each value to the stream.
207+
*
208+
* Calls `stream << value` for each value in the generator, then returns the
209+
* resulting (modified) stream.
210+
*
211+
* \tparam T The type of values in the stream.
212+
* \param[in,out] gen The generator supplying the values.
213+
* \param[in,out] stream The stream to output to.
214+
* \returns The resulting stream.
215+
*/
205216
template <typename T>
206217
std::ostream &to_stream(generator<T> gen, std::ostream &stream) {
207218
while (gen) {
@@ -210,6 +221,21 @@ std::ostream &to_stream(generator<T> gen, std::ostream &stream) {
210221
return stream;
211222
}
212223

224+
/**
225+
* \brief Sends each value to the stream. Values are separated by the given
226+
* separator.
227+
*
228+
* Calls `stream << value` for each value in the generator, then returns the
229+
* resulting (modified) stream. Between each pair of values in the generator,
230+
* the separator is added.
231+
*
232+
* \tparam T The type of values in the stream.
233+
* \tparam T2 The type of the separator.
234+
* \param[in,out] gen The generator supplying the values.
235+
* \param[in,out] stream The stream to output to.
236+
* \param[in] separator The separator to use.
237+
* \returns The resulting stream.
238+
*/
213239
template <typename T, typename T2>
214240
std::ostream &to_stream(generator<T> gen, std::ostream &stream, T2 separator) {
215241
if (gen) {
@@ -221,6 +247,18 @@ std::ostream &to_stream(generator<T> gen, std::ostream &stream, T2 separator) {
221247
return stream;
222248
}
223249

250+
/**
251+
* \brief Sends each value to the stream on a separate line.
252+
*
253+
* Calls `stream << value << std::endl` for each value in the generator, then
254+
* returns the resulting (modified) stream. To avoid a trailing newline, see
255+
* `fpgen::to_lines_no_trail`
256+
*
257+
* \tparam T The type of values in the stream.
258+
* \param[in,out] gen The generator supplying the values.
259+
* \param[in,out] stream The stream to output to.
260+
* \returns The resulting stream.
261+
*/
224262
template <typename T>
225263
std::ostream &to_lines(generator<T> gen, std::ostream &stream) {
226264
while (gen) {
@@ -229,6 +267,18 @@ std::ostream &to_lines(generator<T> gen, std::ostream &stream) {
229267
return stream;
230268
}
231269

270+
/**
271+
* \brief Sends each value to the stream on a separate line, without trailing
272+
* newline.
273+
*
274+
* Calls `stream << std::endl << value` for each value in the generator (except
275+
* the first), then returns the resulting (modified) stream.
276+
*
277+
* \tparam T The type of values in the stream.
278+
* \param[in,out] gen The generator supplying the values.
279+
* \param[in,out] stream The stream to output to.
280+
* \returns The resulting stream.
281+
*/
232282
template <typename T>
233283
std::ostream &to_lines_no_trail(generator<T> gen, std::ostream &stream) {
234284
if (gen) {

0 commit comments

Comments
 (0)