Strike more warnings

This commit is contained in:
Krystian Stasiowski
2020-02-27 16:22:54 -05:00
parent 73b829ebe5
commit bbbc8a6290
2 changed files with 27 additions and 61 deletions

View File

@ -1197,7 +1197,7 @@ public:
basic_static_string& basic_static_string&
assign(const T& t) assign(const T& t)
{ {
string_view_type sv = t; const string_view_type sv = t;
return assign(sv.data(), sv.size()); return assign(sv.data(), sv.size());
} }
@ -1958,7 +1958,8 @@ public:
size_type index, size_type index,
const T& t) const T& t)
{ {
return insert(index, t, 0, npos); const string_view_type sv = t;
return insert(index, sv.data(), sv.size());
} }
/** Insert characters from an object convertible to `string_view_type`. /** Insert characters from an object convertible to `string_view_type`.
@ -2447,7 +2448,7 @@ public:
int int
compare(const T& t) const noexcept compare(const T& t) const noexcept
{ {
string_view_type sv = t; const string_view_type sv = t;
return detail::lexicographical_compare<CharT, Traits>( return detail::lexicographical_compare<CharT, Traits>(
data(), size(), sv.data(), sv.size()); data(), size(), sv.data(), sv.size());
} }
@ -2474,7 +2475,7 @@ public:
size_type count1, size_type count1,
const T& t) const const T& t) const
{ {
string_view_type sv = t; const string_view_type sv = t;
return detail::lexicographical_compare<CharT, Traits>( return detail::lexicographical_compare<CharT, Traits>(
data() + pos1, capped_length(pos1, count1), sv.data(), sv.size()); data() + pos1, capped_length(pos1, count1), sv.data(), sv.size());
} }
@ -2785,7 +2786,7 @@ public:
size_type n1, size_type n1,
const T& t) const T& t)
{ {
string_view_type sv = t; const string_view_type sv = t;
return replace(pos1, n1, sv.data(), sv.size()); return replace(pos1, n1, sv.data(), sv.size());
} }
@ -2837,7 +2838,7 @@ public:
size_type pos2, size_type pos2,
size_type n2 = npos) size_type n2 = npos)
{ {
string_view_type sv = t; const string_view_type sv = t;
return replace(pos1, n1, sv.substr(pos2, n2)); return replace(pos1, n1, sv.substr(pos2, n2));
} }
@ -3043,7 +3044,7 @@ public:
const_iterator i2, const_iterator i2,
const T& t) const T& t)
{ {
string_view_type sv = t; const string_view_type sv = t;
return replace(i1, i2, sv.begin(), sv.end()); return replace(i1, i2, sv.begin(), sv.end());
} }
@ -3306,7 +3307,7 @@ public:
size_type pos = 0) const size_type pos = 0) const
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value) noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
{ {
string_view_type sv = t; const string_view_type sv = t;
return find(sv.data(), pos, sv.size()); return find(sv.data(), pos, sv.size());
} }
@ -3459,7 +3460,7 @@ public:
size_type pos = npos) const size_type pos = npos) const
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value) noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
{ {
string_view_type sv = t; const string_view_type sv = t;
return rfind(sv.data(), pos, sv.size()); return rfind(sv.data(), pos, sv.size());
} }
@ -3607,7 +3608,7 @@ public:
size_type pos = 0) const size_type pos = 0) const
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value) noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
{ {
string_view_type sv = t; const string_view_type sv = t;
return find_first_of(sv.data(), pos, sv.size()); return find_first_of(sv.data(), pos, sv.size());
} }
@ -3750,7 +3751,7 @@ public:
size_type pos = npos) const size_type pos = npos) const
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value) noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
{ {
string_view_type sv = t; const string_view_type sv = t;
return find_last_of(sv.data(), pos, sv.size()); return find_last_of(sv.data(), pos, sv.size());
} }
@ -3892,7 +3893,7 @@ public:
size_type pos = 0) const size_type pos = 0) const
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value) noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
{ {
string_view_type sv = t; const string_view_type sv = t;
return find_first_not_of(sv.data(), pos, sv.size()); return find_first_not_of(sv.data(), pos, sv.size());
} }
@ -4033,7 +4034,7 @@ public:
size_type pos = npos) const size_type pos = npos) const
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value) noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
{ {
string_view_type sv = t; const string_view_type sv = t;
return find_last_not_of(sv.data(), pos, sv.size()); return find_last_not_of(sv.data(), pos, sv.size());
} }

View File

@ -71,7 +71,6 @@ bool
testI(S s, typename S::size_type pos, const typename S::value_type* str, typename S::size_type n, S expected) testI(S s, typename S::size_type pos, const typename S::value_type* str, typename S::size_type n, S expected)
{ {
const typename S::size_type old_size = s.size(); const typename S::size_type old_size = s.size();
S s0 = s;
if (pos <= old_size) if (pos <= old_size)
{ {
s.insert(pos, str, n); s.insert(pos, str, n);
@ -89,7 +88,6 @@ bool
testE(S s, typename S::size_type pos, typename S::size_type n, S expected) testE(S s, typename S::size_type pos, typename S::size_type n, S expected)
{ {
const typename S::size_type old_size = s.size(); const typename S::size_type old_size = s.size();
S s0 = s;
if (pos <= old_size) if (pos <= old_size)
{ {
s.erase(pos, n); s.erase(pos, n);
@ -189,7 +187,6 @@ bool
testR(S s, typename S::size_type pos, typename S::size_type n1, typename S::size_type n2, typename S::value_type c, S expected) testR(S s, typename S::size_type pos, typename S::size_type n1, typename S::size_type n2, typename S::value_type c, S expected)
{ {
const typename S::size_type old_size = s.size(); const typename S::size_type old_size = s.size();
S s0 = s;
if (pos <= old_size) if (pos <= old_size)
{ {
s.replace(pos, n1, n2, c); s.replace(pos, n1, n2, c);
@ -2109,7 +2106,6 @@ testAppend()
S("1234567890123456789012345678901234567890"))); S("1234567890123456789012345678901234567890")));
S s_short = "123/"; S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
s_short.append(s_short.data(), s_short.size()); s_short.append(s_short.data(), s_short.size());
BOOST_TEST(s_short == "123/123/"); BOOST_TEST(s_short == "123/123/");
@ -3764,11 +3760,11 @@ testFind()
BOOST_TEST(fs1.find(cs2, 0, 2) == 1); BOOST_TEST(fs1.find(cs2, 0, 2) == 1);
BOOST_TEST(fs1.find(cs1, 4) == -1); BOOST_TEST(fs1.find(cs1, 4) == S::npos);
BOOST_TEST(fs1.find(cs2, 4) == -1); BOOST_TEST(fs1.find(cs2, 4) == S::npos);
BOOST_TEST(fs1.find('1') == 0); BOOST_TEST(fs1.find('1') == 0);
BOOST_TEST(fs1.find('1', 4) == -1); BOOST_TEST(fs1.find('1', 4) == S::npos);
BOOST_TEST(testF(S(""), "", 0, 0, 0)); BOOST_TEST(testF(S(""), "", 0, 0, 0));
BOOST_TEST(testF(S(""), "abcde", 0, 0, 0)); BOOST_TEST(testF(S(""), "abcde", 0, 0, 0));
@ -4071,22 +4067,6 @@ testFind()
BOOST_TEST(testF(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos)); BOOST_TEST(testF(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos));
BOOST_TEST(testF(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20)); BOOST_TEST(testF(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20));
// rfind // rfind
BOOST_TEST(fs1.rfind(v1) == 0); BOOST_TEST(fs1.rfind(v1) == 0);
@ -4099,9 +4079,9 @@ testFind()
BOOST_TEST(fs1.rfind(cs2) == 1); BOOST_TEST(fs1.rfind(cs2) == 1);
BOOST_TEST(fs1.rfind(cs1, 0) == 0); BOOST_TEST(fs1.rfind(cs1, 0) == 0);
BOOST_TEST(fs1.rfind(cs2, 0) == -1); BOOST_TEST(fs1.rfind(cs2, 0) == S::npos);
BOOST_TEST(fs1.rfind(cs2, 0, 2) == -1); BOOST_TEST(fs1.rfind(cs2, 0, 2) == S::npos);
BOOST_TEST(fs1.rfind(cs1, 4) == 0); BOOST_TEST(fs1.rfind(cs1, 4) == 0);
BOOST_TEST(fs1.rfind('1') == 0); BOOST_TEST(fs1.rfind('1') == 0);
@ -4409,15 +4389,6 @@ testFind()
BOOST_TEST(testRF(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10)); BOOST_TEST(testRF(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10));
BOOST_TEST(testRF(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20)); BOOST_TEST(testRF(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20));
// find_first_of // find_first_of
BOOST_TEST(fs1.find_first_of(v1) == 0); BOOST_TEST(fs1.find_first_of(v1) == 0);
@ -4437,7 +4408,7 @@ testFind()
BOOST_TEST(fs1.find_first_of(cs2, 4) == 4); BOOST_TEST(fs1.find_first_of(cs2, 4) == 4);
BOOST_TEST(fs1.find_first_of('1') == 0); BOOST_TEST(fs1.find_first_of('1') == 0);
BOOST_TEST(fs1.find_first_of('1', 4) == -1); BOOST_TEST(fs1.find_first_of('1', 4) == S::npos);
BOOST_TEST(testFF(S(""), "", 0, 0, S::npos)); BOOST_TEST(testFF(S(""), "", 0, 0, S::npos));
BOOST_TEST(testFF(S(""), "irkhs", 0, 0, S::npos)); BOOST_TEST(testFF(S(""), "irkhs", 0, 0, S::npos));
@ -4740,13 +4711,6 @@ testFind()
BOOST_TEST(testFF(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos)); BOOST_TEST(testFF(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos));
BOOST_TEST(testFF(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos)); BOOST_TEST(testFF(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos));
// find_last_of // find_last_of
BOOST_TEST(fs1.find_last_of(v1) == 4); BOOST_TEST(fs1.find_last_of(v1) == 4);
@ -4758,15 +4722,15 @@ testFind()
BOOST_TEST(fs1.find_last_of(cs2) == 4); BOOST_TEST(fs1.find_last_of(cs2) == 4);
BOOST_TEST(fs1.find_last_of(cs1, 0) == 0); BOOST_TEST(fs1.find_last_of(cs1, 0) == 0);
BOOST_TEST(fs1.find_last_of(cs2, 0) == -1); BOOST_TEST(fs1.find_last_of(cs2, 0) == S::npos);
BOOST_TEST(fs1.find_last_of(cs2, 0, 2) == -1); BOOST_TEST(fs1.find_last_of(cs2, 0, 2) == S::npos);
BOOST_TEST(fs1.find_last_of(cs1, 4) == 4); BOOST_TEST(fs1.find_last_of(cs1, 4) == 4);
BOOST_TEST(fs1.find_last_of(cs2, 4) == 4); BOOST_TEST(fs1.find_last_of(cs2, 4) == 4);
BOOST_TEST(fs1.find_last_of('1') == 0); BOOST_TEST(fs1.find_last_of('1') == 0);
BOOST_TEST(fs1.find_last_of('5', 3) == -1); BOOST_TEST(fs1.find_last_of('5', 3) == S::npos);
BOOST_TEST(testFL(S(""), "", 0, 0, S::npos)); BOOST_TEST(testFL(S(""), "", 0, 0, S::npos));
BOOST_TEST(testFL(S(""), "irkhs", 0, 0, S::npos)); BOOST_TEST(testFL(S(""), "irkhs", 0, 0, S::npos));
@ -5117,8 +5081,8 @@ testFind()
BOOST_TEST(fs1.find_first_not_of(cs4, 0, 2) == 0); BOOST_TEST(fs1.find_first_not_of(cs4, 0, 2) == 0);
BOOST_TEST(fs1.find_first_not_of(cs3, 4) == -1); BOOST_TEST(fs1.find_first_not_of(cs3, 4) == S::npos);
BOOST_TEST(fs1.find_first_not_of(cs4, 4) == -1); BOOST_TEST(fs1.find_first_not_of(cs4, 4) == S::npos);
BOOST_TEST(fs1.find_first_not_of('1') == 1); BOOST_TEST(fs1.find_first_not_of('1') == 1);
BOOST_TEST(fs1.find_first_not_of('1', 3) == 3); BOOST_TEST(fs1.find_first_not_of('1', 3) == 3);
@ -5458,7 +5422,7 @@ testFind()
BOOST_TEST(fs1.find_last_not_of(cs3) == 2); BOOST_TEST(fs1.find_last_not_of(cs3) == 2);
BOOST_TEST(fs1.find_last_not_of(cs4) == 3); BOOST_TEST(fs1.find_last_not_of(cs4) == 3);
BOOST_TEST(fs1.find_last_not_of(cs3, 0) == -1); BOOST_TEST(fs1.find_last_not_of(cs3, 0) == S::npos);
BOOST_TEST(fs1.find_last_not_of(cs4, 0) == 0); BOOST_TEST(fs1.find_last_not_of(cs4, 0) == 0);
BOOST_TEST(fs1.find_last_not_of(cs4, 0, 2) == 0); BOOST_TEST(fs1.find_last_not_of(cs4, 0, 2) == 0);
@ -7149,6 +7113,7 @@ int
runTests() runTests()
{ {
constexpr auto cxper = testConstantEvaluation(); constexpr auto cxper = testConstantEvaluation();
static_cast<void>(cxper);
testConstruct(); testConstruct();