@@ -16,21 +16,20 @@ namespace fly::detail {
16
16
* @author Timothy Flynn ([email protected] )
17
17
* @version January 3, 2021
18
18
*/
19
- template <typename StringType>
20
- class BasicStreamModifiers
19
+ class ScopedStreamModifiers
21
20
{
22
21
public:
23
22
/* *
24
23
* Constructor. Store the stream's current state to be restored upon destruction.
25
24
*
26
25
* @param stream The stream to be modified.
27
26
*/
28
- explicit BasicStreamModifiers (std::ostream &stream) noexcept ;
27
+ explicit ScopedStreamModifiers (std::ostream &stream) noexcept ;
29
28
30
29
/* *
31
30
* Destructor. Restore the stream's orginal state.
32
31
*/
33
- ~BasicStreamModifiers ();
32
+ ~ScopedStreamModifiers ();
34
33
35
34
/* *
36
35
* Sets a formatting flag on the stream.
@@ -77,8 +76,8 @@ class BasicStreamModifiers
77
76
void precision (std::streamsize size);
78
77
79
78
private:
80
- BasicStreamModifiers (const BasicStreamModifiers &) = delete ;
81
- BasicStreamModifiers &operator =(const BasicStreamModifiers &) = delete ;
79
+ ScopedStreamModifiers (const ScopedStreamModifiers &) = delete ;
80
+ ScopedStreamModifiers &operator =(const ScopedStreamModifiers &) = delete ;
82
81
83
82
std::ostream &m_stream;
84
83
@@ -119,8 +118,7 @@ class PositivePaddingFacet : public std::ctype<CharType>
119
118
};
120
119
121
120
// ==================================================================================================
122
- template <typename StringType>
123
- BasicStreamModifiers<StringType>::BasicStreamModifiers(std::ostream &stream) noexcept :
121
+ inline ScopedStreamModifiers::ScopedStreamModifiers (std::ostream &stream) noexcept :
124
122
m_stream(stream),
125
123
m_flags(stream.flags()),
126
124
m_locale(stream.getloc()),
@@ -131,8 +129,7 @@ BasicStreamModifiers<StringType>::BasicStreamModifiers(std::ostream &stream) noe
131
129
}
132
130
133
131
// ==================================================================================================
134
- template <typename StringType>
135
- BasicStreamModifiers<StringType>::~BasicStreamModifiers ()
132
+ inline ScopedStreamModifiers::~ScopedStreamModifiers ()
136
133
{
137
134
if (m_changed_flags)
138
135
{
@@ -157,50 +154,43 @@ BasicStreamModifiers<StringType>::~BasicStreamModifiers()
157
154
}
158
155
159
156
// ==================================================================================================
160
- template <typename StringType>
161
- inline void BasicStreamModifiers<StringType>::setf(std::ios_base::fmtflags flag)
157
+ inline void ScopedStreamModifiers::setf (std::ios_base::fmtflags flag)
162
158
{
163
159
m_stream.setf (flag);
164
160
m_changed_flags = true ;
165
161
}
166
162
167
163
// ==================================================================================================
168
- template <typename StringType>
169
- inline void
170
- BasicStreamModifiers<StringType>::setf(std::ios_base::fmtflags flag, std::ios_base::fmtflags mask)
164
+ inline void ScopedStreamModifiers::setf (std::ios_base::fmtflags flag, std::ios_base::fmtflags mask)
171
165
{
172
166
m_stream.setf (flag, mask);
173
167
m_changed_flags = true ;
174
168
}
175
169
176
170
// ==================================================================================================
177
- template <typename StringType>
178
171
template <typename Facet>
179
- inline void BasicStreamModifiers<StringType> ::locale()
172
+ inline void ScopedStreamModifiers ::locale ()
180
173
{
181
174
m_stream.imbue ({m_stream.getloc (), new Facet ()});
182
175
m_changed_locale = true ;
183
176
}
184
177
185
178
// ==================================================================================================
186
- template <typename StringType>
187
- inline void BasicStreamModifiers<StringType>::fill(char ch)
179
+ inline void ScopedStreamModifiers::fill (char ch)
188
180
{
189
181
m_stream.fill (ch);
190
182
m_changed_fill = true ;
191
183
}
192
184
193
185
// ==================================================================================================
194
- template <typename StringType>
195
- inline void BasicStreamModifiers<StringType>::width(std::streamsize size)
186
+ inline void ScopedStreamModifiers::width (std::streamsize size)
196
187
{
197
188
m_stream.width (size);
198
189
m_changed_width = true ;
199
190
}
200
191
201
192
// ==================================================================================================
202
- template <typename StringType>
203
- inline void BasicStreamModifiers<StringType>::precision(std::streamsize size)
193
+ inline void ScopedStreamModifiers::precision (std::streamsize size)
204
194
{
205
195
m_stream.precision (size);
206
196
m_changed_precision = true ;
0 commit comments