Skip to content
This repository was archived by the owner on Jun 15, 2025. It is now read-only.

Commit c4aa01e

Browse files
committed
fix #19: clang-tidy requires auto
1 parent 964b521 commit c4aa01e

File tree

1 file changed

+42
-53
lines changed

1 file changed

+42
-53
lines changed

include/spsl/stringbase.hpp

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,38 @@ class StringBase : public StringCore<StorageType>
4949
using reverse_iterator = typename base_type::reverse_iterator;
5050

5151
// "inherit" everything else as well
52-
using base_type::npos;
53-
using base_type::nul;
5452
using base_type::assign;
5553
using base_type::c_str;
5654
using base_type::data;
55+
using base_type::npos;
56+
using base_type::nul;
5757
using base_type::operator[];
58+
using base_type::append;
5859
using base_type::at;
59-
using base_type::front;
6060
using base_type::back;
6161
using base_type::begin;
62+
using base_type::capacity;
6263
using base_type::cbegin;
63-
using base_type::rbegin;
64-
using base_type::crbegin;
65-
using base_type::end;
6664
using base_type::cend;
67-
using base_type::rend;
65+
using base_type::clear;
66+
using base_type::copy;
67+
using base_type::crbegin;
6868
using base_type::crend;
6969
using base_type::empty;
70-
using base_type::max_size;
71-
using base_type::capacity;
70+
using base_type::end;
71+
using base_type::front;
7272
using base_type::length;
73-
using base_type::size;
73+
using base_type::max_size;
74+
using base_type::pop_back;
75+
using base_type::push_back;
76+
using base_type::rbegin;
77+
using base_type::rend;
7478
using base_type::reserve;
79+
using base_type::resize;
7580
using base_type::shrink_to_fit;
76-
using base_type::clear;
77-
using base_type::push_back;
78-
using base_type::pop_back;
81+
using base_type::size;
7982
using base_type::substr;
80-
using base_type::copy;
81-
using base_type::resize;
8283
using base_type::swap;
83-
using base_type::append;
8484
using base_type::operator+=;
8585
using base_type::compare;
8686
using base_type::find;
@@ -107,9 +107,8 @@ class StringBase : public StringCore<StorageType>
107107
explicit StringBase(const storage_type& storage) : base_type(storage) {}
108108

109109
/// construct from another string-like container (may even be a vector...)
110-
template <typename StringClass,
111-
typename std::enable_if<
112-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
110+
template <typename StringClass, typename std::enable_if<is_compatible_string<
111+
char_type, size_type, StringClass>::value>::type* = nullptr>
113112
explicit StringBase(const StringClass& s) : base_type(s)
114113
{
115114
}
@@ -142,9 +141,8 @@ class StringBase : public StringCore<StorageType>
142141
}
143142

144143
/// allow assignment from another string-like container (may even be a vector...)
145-
template <typename StringClass,
146-
typename std::enable_if<
147-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
144+
template <typename StringClass, typename std::enable_if<is_compatible_string<
145+
char_type, size_type, StringClass>::value>::type* = nullptr>
148146
this_type& operator=(const StringClass& s)
149147
{
150148
assign(s.data(), s.size());
@@ -197,17 +195,15 @@ class StringBase : public StringCore<StorageType>
197195
return *this;
198196
}
199197
// another string-like class
200-
template <typename StringClass,
201-
typename std::enable_if<
202-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
198+
template <typename StringClass, typename std::enable_if<is_compatible_string<
199+
char_type, size_type, StringClass>::value>::type* = nullptr>
203200
this_type& insert(size_type index, const StringClass& s)
204201
{
205202
return insert(index, s.data(), s.size());
206203
}
207204
// another string-like class with index and count
208-
template <typename StringClass,
209-
typename std::enable_if<
210-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
205+
template <typename StringClass, typename std::enable_if<is_compatible_string<
206+
char_type, size_type, StringClass>::value>::type* = nullptr>
211207
this_type& insert(size_type index, const StringClass& s, size_type index_str,
212208
size_type count = npos)
213209
{
@@ -248,7 +244,7 @@ class StringBase : public StringCore<StorageType>
248244
if (position < cbegin() || position > cend())
249245
throw std::out_of_range("invalid iterator in erase()");
250246

251-
size_type pos = static_cast<size_type>(position - cbegin());
247+
auto pos = static_cast<size_type>(position - cbegin());
252248
m_storage.erase(pos, 1);
253249
return begin() + pos;
254250
}
@@ -257,8 +253,8 @@ class StringBase : public StringCore<StorageType>
257253
if (first < cbegin() || last > cend() || first > last)
258254
throw std::out_of_range("invalid iterator(s) in erase()");
259255

260-
size_type pos = static_cast<size_type>(first - cbegin());
261-
size_type cnt = static_cast<size_type>(last - first);
256+
auto pos = static_cast<size_type>(first - cbegin());
257+
auto cnt = static_cast<size_type>(last - first);
262258
m_storage.erase(pos, cnt);
263259
return begin() + pos;
264260
}
@@ -333,26 +329,23 @@ class StringBase : public StringCore<StorageType>
333329
ilist.begin(), ilist.size());
334330
}
335331

336-
template <typename StringClass,
337-
typename std::enable_if<
338-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
332+
template <typename StringClass, typename std::enable_if<is_compatible_string<
333+
char_type, size_type, StringClass>::value>::type* = nullptr>
339334
this_type& replace(size_type pos, size_type count, const StringClass& s)
340335
{
341336
return replace(pos, count, s.data(), s.size());
342337
}
343338

344-
template <typename StringClass,
345-
typename std::enable_if<
346-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
339+
template <typename StringClass, typename std::enable_if<is_compatible_string<
340+
char_type, size_type, StringClass>::value>::type* = nullptr>
347341
this_type& replace(const_iterator first, const_iterator last, const StringClass& s)
348342
{
349343
return replace(static_cast<size_type>(first - data()), static_cast<size_type>(last - first),
350344
s.data(), s.size());
351345
}
352346

353-
template <typename StringClass,
354-
typename std::enable_if<
355-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
347+
template <typename StringClass, typename std::enable_if<is_compatible_string<
348+
char_type, size_type, StringClass>::value>::type* = nullptr>
356349
this_type& replace(size_type pos, size_type count, const StringClass& s, size_type pos2,
357350
size_type count2 = npos)
358351
{
@@ -389,9 +382,8 @@ class StringBase : public StringCore<StorageType>
389382
{
390383
return find_first_of(s, pos, traits_type::length(s));
391384
}
392-
template <typename StringClass,
393-
typename std::enable_if<
394-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
385+
template <typename StringClass, typename std::enable_if<is_compatible_string<
386+
char_type, size_type, StringClass>::value>::type* = nullptr>
395387
size_type find_first_of(const StringClass& s, size_type pos = 0) const noexcept
396388
{
397389
return find_first_of(s.data(), pos, s.size());
@@ -428,9 +420,8 @@ class StringBase : public StringCore<StorageType>
428420
{
429421
return find_first_not_of(s, pos, traits_type::length(s));
430422
}
431-
template <typename StringClass,
432-
typename std::enable_if<
433-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
423+
template <typename StringClass, typename std::enable_if<is_compatible_string<
424+
char_type, size_type, StringClass>::value>::type* = nullptr>
434425
size_type find_first_not_of(const StringClass& s, size_type pos = 0) const noexcept
435426
{
436427
return find_first_not_of(s.data(), pos, s.size());
@@ -466,9 +457,8 @@ class StringBase : public StringCore<StorageType>
466457
{
467458
return find_last_of(s, pos, traits_type::length(s));
468459
}
469-
template <typename StringClass,
470-
typename std::enable_if<
471-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
460+
template <typename StringClass, typename std::enable_if<is_compatible_string<
461+
char_type, size_type, StringClass>::value>::type* = nullptr>
472462
size_type find_last_of(const StringClass& s, size_type pos = npos) const noexcept
473463
{
474464
return find_last_of(s.data(), pos, s.size());
@@ -519,9 +509,8 @@ class StringBase : public StringCore<StorageType>
519509
{
520510
return find_last_not_of(s, pos, traits_type::length(s));
521511
}
522-
template <typename StringClass,
523-
typename std::enable_if<
524-
is_compatible_string<char_type, size_type, StringClass>::value>::type* = nullptr>
512+
template <typename StringClass, typename std::enable_if<is_compatible_string<
513+
char_type, size_type, StringClass>::value>::type* = nullptr>
525514
size_type find_last_not_of(const StringClass& s, size_type pos = npos) const noexcept
526515
{
527516
return find_last_not_of(s.data(), pos, s.size());
@@ -573,6 +562,6 @@ struct hash<spsl::StringBase<StorageType>>
573562
return spsl::hash::hash_impl(s.data(), s.size() * sizeof(char_type));
574563
}
575564
};
576-
}
565+
} // namespace std
577566

578567
#endif /* SPSL_STRINGBASE_HPP_ */

0 commit comments

Comments
 (0)