diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index 7f78a30..aae7f25 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -164,6 +164,11 @@ namespace boost { std::basic_string to_string() const { return std::basic_string(begin(), end()); } + + template + std::basic_string to_string(const Allocator& a) const { + return std::basic_string(begin(), end(), a); + } #endif size_type copy(charT* s, size_type n, size_type pos=0) const { @@ -215,7 +220,7 @@ namespace boost { // Searches BOOST_CONSTEXPR bool starts_with(charT c) const BOOST_NOEXCEPT { // Boost extension return !empty() && traits::eq(c, front()); - } + } BOOST_CONSTEXPR bool starts_with(basic_string_view x) const BOOST_NOEXCEPT { // Boost extension return len_ >= x.len_ && traits::compare(ptr_, x.ptr_, x.len_) == 0; @@ -226,7 +231,7 @@ namespace boost { } BOOST_CONSTEXPR bool ends_with(basic_string_view x) const BOOST_NOEXCEPT { // Boost extension - return len_ >= x.len_ && + return len_ >= x.len_ && traits::compare(ptr_ + len_ - x.len_, x.ptr_, x.len_) == 0; } @@ -251,7 +256,7 @@ namespace boost { BOOST_CXX14_CONSTEXPR size_type rfind(basic_string_view s, size_type pos = npos) const BOOST_NOEXCEPT { if (len_ < s.len_) return npos; - if (pos > len_ - s.len_) + if (pos > len_ - s.len_) pos = len_ - s.len_; if (s.len_ == 0u) // an empty string is always found return pos; @@ -368,7 +373,7 @@ namespace boost { // Inequality template inline bool operator!=(basic_string_view x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { if ( x.size () != y.size ()) return true; return x.compare(y) != 0; } @@ -376,173 +381,173 @@ namespace boost { // Less than template inline bool operator<(basic_string_view x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return x.compare(y) < 0; } // Greater than template inline bool operator>(basic_string_view x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return x.compare(y) > 0; } // Less than or equal to template inline bool operator<=(basic_string_view x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return x.compare(y) <= 0; } // Greater than or equal to template inline bool operator>=(basic_string_view x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return x.compare(y) >= 0; } // "sufficient additional overloads of comparison functions" template inline bool operator==(basic_string_view x, - const std::basic_string & y) BOOST_NOEXCEPT { + const std::basic_string & y) BOOST_NOEXCEPT { return x == basic_string_view(y); } template inline bool operator==(const std::basic_string & x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) == y; } template inline bool operator==(basic_string_view x, - const charT * y) BOOST_NOEXCEPT { + const charT * y) BOOST_NOEXCEPT { return x == basic_string_view(y); } template inline bool operator==(const charT * x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) == y; } template inline bool operator!=(basic_string_view x, - const std::basic_string & y) BOOST_NOEXCEPT { + const std::basic_string & y) BOOST_NOEXCEPT { return x != basic_string_view(y); } template inline bool operator!=(const std::basic_string & x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) != y; } template inline bool operator!=(basic_string_view x, - const charT * y) BOOST_NOEXCEPT { + const charT * y) BOOST_NOEXCEPT { return x != basic_string_view(y); } template inline bool operator!=(const charT * x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) != y; } template inline bool operator<(basic_string_view x, - const std::basic_string & y) BOOST_NOEXCEPT { + const std::basic_string & y) BOOST_NOEXCEPT { return x < basic_string_view(y); } template inline bool operator<(const std::basic_string & x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) < y; } template inline bool operator<(basic_string_view x, - const charT * y) BOOST_NOEXCEPT { + const charT * y) BOOST_NOEXCEPT { return x < basic_string_view(y); } template inline bool operator<(const charT * x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) < y; } template inline bool operator>(basic_string_view x, - const std::basic_string & y) BOOST_NOEXCEPT { + const std::basic_string & y) BOOST_NOEXCEPT { return x > basic_string_view(y); } template inline bool operator>(const std::basic_string & x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) > y; } template inline bool operator>(basic_string_view x, - const charT * y) BOOST_NOEXCEPT { + const charT * y) BOOST_NOEXCEPT { return x > basic_string_view(y); } template inline bool operator>(const charT * x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) > y; } template inline bool operator<=(basic_string_view x, - const std::basic_string & y) BOOST_NOEXCEPT { + const std::basic_string & y) BOOST_NOEXCEPT { return x <= basic_string_view(y); } template inline bool operator<=(const std::basic_string & x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) <= y; } template inline bool operator<=(basic_string_view x, - const charT * y) BOOST_NOEXCEPT { + const charT * y) BOOST_NOEXCEPT { return x <= basic_string_view(y); } template inline bool operator<=(const charT * x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) <= y; } template inline bool operator>=(basic_string_view x, - const std::basic_string & y) BOOST_NOEXCEPT { + const std::basic_string & y) BOOST_NOEXCEPT { return x >= basic_string_view(y); } template inline bool operator>=(const std::basic_string & x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) >= y; } template inline bool operator>=(basic_string_view x, - const charT * y) BOOST_NOEXCEPT { + const charT * y) BOOST_NOEXCEPT { return x >= basic_string_view(y); } template inline bool operator>=(const charT * x, - basic_string_view y) BOOST_NOEXCEPT { + basic_string_view y) BOOST_NOEXCEPT { return basic_string_view(x) >= y; }