Skip to content

Commit ec21bd0

Browse files
committed
Remove template parameter from ScopedStreamModifiers
And rename it from BasicStreamModifiers to ScopedStreamModifiers.
1 parent bc09749 commit ec21bd0

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

bench/util/table.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void Table<Args...>::append_row(Args... args)
231231
template <class... Args>
232232
void Table<Args...>::print_table(std::ostream &stream) const
233233
{
234-
fly::detail::BasicStreamModifiers<std::string> scoped_modifiers(stream);
234+
fly::detail::ScopedStreamModifiers scoped_modifiers(stream);
235235
scoped_modifiers.locale<CommaPunctuation>();
236236

237237
// Compute the entire width of the table. There are 1 + the number of columns vertical

fly/types/string/detail/stream_util.hpp

+13-23
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,20 @@ namespace fly::detail {
1616
* @author Timothy Flynn ([email protected])
1717
* @version January 3, 2021
1818
*/
19-
template <typename StringType>
20-
class BasicStreamModifiers
19+
class ScopedStreamModifiers
2120
{
2221
public:
2322
/**
2423
* Constructor. Store the stream's current state to be restored upon destruction.
2524
*
2625
* @param stream The stream to be modified.
2726
*/
28-
explicit BasicStreamModifiers(std::ostream &stream) noexcept;
27+
explicit ScopedStreamModifiers(std::ostream &stream) noexcept;
2928

3029
/**
3130
* Destructor. Restore the stream's orginal state.
3231
*/
33-
~BasicStreamModifiers();
32+
~ScopedStreamModifiers();
3433

3534
/**
3635
* Sets a formatting flag on the stream.
@@ -77,8 +76,8 @@ class BasicStreamModifiers
7776
void precision(std::streamsize size);
7877

7978
private:
80-
BasicStreamModifiers(const BasicStreamModifiers &) = delete;
81-
BasicStreamModifiers &operator=(const BasicStreamModifiers &) = delete;
79+
ScopedStreamModifiers(const ScopedStreamModifiers &) = delete;
80+
ScopedStreamModifiers &operator=(const ScopedStreamModifiers &) = delete;
8281

8382
std::ostream &m_stream;
8483

@@ -119,8 +118,7 @@ class PositivePaddingFacet : public std::ctype<CharType>
119118
};
120119

121120
//==================================================================================================
122-
template <typename StringType>
123-
BasicStreamModifiers<StringType>::BasicStreamModifiers(std::ostream &stream) noexcept :
121+
inline ScopedStreamModifiers::ScopedStreamModifiers(std::ostream &stream) noexcept :
124122
m_stream(stream),
125123
m_flags(stream.flags()),
126124
m_locale(stream.getloc()),
@@ -131,8 +129,7 @@ BasicStreamModifiers<StringType>::BasicStreamModifiers(std::ostream &stream) noe
131129
}
132130

133131
//==================================================================================================
134-
template <typename StringType>
135-
BasicStreamModifiers<StringType>::~BasicStreamModifiers()
132+
inline ScopedStreamModifiers::~ScopedStreamModifiers()
136133
{
137134
if (m_changed_flags)
138135
{
@@ -157,50 +154,43 @@ BasicStreamModifiers<StringType>::~BasicStreamModifiers()
157154
}
158155

159156
//==================================================================================================
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)
162158
{
163159
m_stream.setf(flag);
164160
m_changed_flags = true;
165161
}
166162

167163
//==================================================================================================
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)
171165
{
172166
m_stream.setf(flag, mask);
173167
m_changed_flags = true;
174168
}
175169

176170
//==================================================================================================
177-
template <typename StringType>
178171
template <typename Facet>
179-
inline void BasicStreamModifiers<StringType>::locale()
172+
inline void ScopedStreamModifiers::locale()
180173
{
181174
m_stream.imbue({m_stream.getloc(), new Facet()});
182175
m_changed_locale = true;
183176
}
184177

185178
//==================================================================================================
186-
template <typename StringType>
187-
inline void BasicStreamModifiers<StringType>::fill(char ch)
179+
inline void ScopedStreamModifiers::fill(char ch)
188180
{
189181
m_stream.fill(ch);
190182
m_changed_fill = true;
191183
}
192184

193185
//==================================================================================================
194-
template <typename StringType>
195-
inline void BasicStreamModifiers<StringType>::width(std::streamsize size)
186+
inline void ScopedStreamModifiers::width(std::streamsize size)
196187
{
197188
m_stream.width(size);
198189
m_changed_width = true;
199190
}
200191

201192
//==================================================================================================
202-
template <typename StringType>
203-
inline void BasicStreamModifiers<StringType>::precision(std::streamsize size)
193+
inline void ScopedStreamModifiers::precision(std::streamsize size)
204194
{
205195
m_stream.precision(size);
206196
m_changed_precision = true;

fly/types/string/string_formatters.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ struct Formatter<T, CharType, fly::enable_if<std::is_floating_point<T>>>
219219

220220
private:
221221
using string_type = std::basic_string<CharType>;
222-
using stream_modifiers = detail::BasicStreamModifiers<string_type>;
223222
using specifier = detail::BasicFormatSpecifier<CharType>;
224223

225224
static constexpr const auto s_zero = FLY_CHR(CharType, '0');
@@ -646,7 +645,7 @@ void Formatter<T, CharType, fly::enable_if<std::is_floating_point<T>>>::format(
646645
FormatContext &context)
647646
{
648647
static thread_local std::stringstream s_stream;
649-
stream_modifiers modifiers(s_stream);
648+
detail::ScopedStreamModifiers modifiers(s_stream);
650649

651650
if (context.spec().m_alignment == specifier::Alignment::Default)
652651
{

0 commit comments

Comments
 (0)