Version: SMASH-3.4
iomanipulators.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2015,2017-2018,2020
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_IOMANIPULATORS_H_
11 #define SRC_INCLUDE_SMASH_IOMANIPULATORS_H_
12 
13 #include <ostream>
14 
15 namespace smash {
16 
17 /**
18  * \ingroup logging
19  *
20  * Stream modifier to align the next object to a specific width \p w.
21  *
22  * \tparam w The number of characters the field should have in the output.
23  * \tparam p The floating precision.
24  * \tparam CharT Character type of the output stream.
25  * \tparam Traits Traits of the output stream.
26  * \param[inout] s The output stream.
27  * \return The output stream.
28  */
29 template <int w = 9, int p = w - 3, typename CharT, typename Traits>
30 inline std::basic_ostream<CharT, Traits> &field(
31  std::basic_ostream<CharT, Traits> &s) {
32  s.put(s.widen(' '));
33  s.setf(std::ios_base::fixed, std::ios_base::floatfield);
34  s.width(w);
35  s.precision(p);
36  return s;
37 }
38 
39 } // namespace smash
40 
41 #endif // SRC_INCLUDE_SMASH_IOMANIPULATORS_H_
std::basic_ostream< CharT, Traits > & field(std::basic_ostream< CharT, Traits > &s)
Stream modifier to align the next object to a specific width w.
constexpr int p
Proton.
Definition: action.h:24