Removed more string_view dependency

This commit is contained in:
Krystian Stasiowski
2019-10-27 17:18:19 -04:00
parent 9156aa8ec8
commit 79df90dde0
3 changed files with 21 additions and 10 deletions

View File

@ -40,6 +40,8 @@ lexicographical_compare(
return Traits::compare(s1, s2, n1); return Traits::compare(s1, s2, n1);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename CharT, typename Traits> template<typename CharT, typename Traits>
int int
lexicographical_compare( lexicographical_compare(
@ -49,7 +51,9 @@ lexicographical_compare(
return detail::lexicographical_compare< return detail::lexicographical_compare<
CharT, Traits>(s1.data(), s1.size(), s2, n2); CharT, Traits>(s1.data(), s1.size(), s2, n2);
} }
#endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename CharT, typename Traits> template<typename CharT, typename Traits>
int int
lexicographical_compare( lexicographical_compare(
@ -59,6 +63,7 @@ lexicographical_compare(
return detail::lexicographical_compare<CharT, Traits>( return detail::lexicographical_compare<CharT, Traits>(
s1.data(), s1.size(), s2.data(), s2.size()); s1.data(), s1.size(), s2.data(), s2.size());
} }
#endif
// Maximum number of characters in the decimal // Maximum number of characters in the decimal
// representation of a binary number. This includes // representation of a binary number. This includes

View File

@ -1414,7 +1414,7 @@ public:
const_iterator i2, const_iterator i2,
const fixed_string& str) const fixed_string& str)
{ {
return replace(i1, i2, string_view_type(str)); return replace(i1, i2, str.data(), str.size());
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW #ifdef BOOST_FIXED_STRING_STRING_VIEW
@ -1444,7 +1444,7 @@ public:
const CharT* s, const CharT* s,
size_type n) size_type n)
{ {
return replace(i1, i2, string_view_type(s, n)); return replace(i1 - begin(), i2 - i1, s, n);
} }
fixed_string& fixed_string&
@ -1453,7 +1453,7 @@ public:
const_iterator i2, const_iterator i2,
const CharT* s) const CharT* s)
{ {
return replace(i1, i2, string_view_type(s)); return replace(i1, i2, s, Traits::length(s));
} }
fixed_string& fixed_string&
@ -1889,7 +1889,7 @@ public:
starts_with( starts_with(
string_view_type s) const noexcept string_view_type s) const noexcept
{ {
return string_view_type(*this).starts_with(s); return starts_with(s.data());
} }
#endif #endif
@ -1897,14 +1897,15 @@ public:
starts_with( starts_with(
CharT c) const noexcept CharT c) const noexcept
{ {
return string_view_type(*this).starts_with(c); return !empty() && Traits::eq(front(), c);
} }
bool bool
starts_with( starts_with(
const CharT* s) const const CharT* s) const
{ {
return string_view_type(*this).starts_with(s); const size_type len = Traits::length(s);
return n_ >= len && !Traits::compare(s_, s, len);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW #ifdef BOOST_FIXED_STRING_STRING_VIEW
@ -1912,7 +1913,7 @@ public:
ends_with( ends_with(
string_view_type s) const noexcept string_view_type s) const noexcept
{ {
return string_view_type(*this).ends_with(s); return ends_with(s.data());
} }
#endif #endif
@ -1920,14 +1921,15 @@ public:
ends_with( ends_with(
CharT c) const noexcept CharT c) const noexcept
{ {
return string_view_type(*this).ends_with(c); return !empty() && Traits::eq(back(), c);
} }
bool bool
ends_with( ends_with(
const CharT* s) const const CharT* s) const
{ {
return string_view_type(*this).ends_with(s); const size_type len = Traits::length(s);
return n_ >= len && !Traits::compare(s_ + (n_ - len), s, len);
} }
private: private:
@ -2215,6 +2217,7 @@ swap(
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<std::size_t N, typename CharT, typename Traits> template<std::size_t N, typename CharT, typename Traits>
std::basic_ostream<CharT, Traits>& std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, operator<<(std::basic_ostream<CharT, Traits>& os,
@ -2223,6 +2226,7 @@ operator<<(std::basic_ostream<CharT, Traits>& os,
return os << static_cast< return os << static_cast<
string_view>(s); string_view>(s);
} }
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// //

View File

@ -125,6 +125,7 @@ fixed_string(string_view_type sv)
} }
#endif #endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<std::size_t N, typename CharT, typename Traits> template<std::size_t N, typename CharT, typename Traits>
template<class T, class> template<class T, class>
fixed_string<N, CharT, Traits>:: fixed_string<N, CharT, Traits>::
@ -132,6 +133,7 @@ fixed_string(T const& t, size_type pos, size_type n)
{ {
assign(t, pos, n); assign(t, pos, n);
} }
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// //