This is an automated email from the ASF dual-hosted git repository. amc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 10670b9 string_view: Remove C++14 operators to avoid ambiguity. Undo TextView hack. 10670b9 is described below commit 10670b95ced3afa984dc3a7056c127b1abb06be5 Author: Alan M. Carroll <a...@apache.org> AuthorDate: Tue Apr 10 19:00:29 2018 -0500 string_view: Remove C++14 operators to avoid ambiguity. Undo TextView hack. --- lib/ts/TextView.h | 16 ----- lib/ts/string_view.h | 176 --------------------------------------------------- 2 files changed, 192 deletions(-) diff --git a/lib/ts/TextView.h b/lib/ts/TextView.h index 4980fd6..3a89d0a 100644 --- a/lib/ts/TextView.h +++ b/lib/ts/TextView.h @@ -973,22 +973,6 @@ TextView::trim_if(F const &pred) return this->ltrim_if(pred).rtrim_if(pred); } -#if __GNUC__ == 6 -// The super class operators are ambiguous in GCC 6, but not in 5 or 7. -// As best I can tell, TextView isn't recognized as a subclass of string_view in template deduction. -bool inline -operator==(TextView lhs, TextView rhs) -{ - return lhs.size() == rhs.size() && 0 == memcmp(lhs.data(), rhs.data(), lhs.size()); -} - -bool inline -operator!=(TextView lhs, TextView rhs) -{ - return lhs.size() != rhs.size() || 0 != memcmp(lhs.data(), rhs.data(), lhs.size()); -} -#endif - inline bool TextView::isPrefixOf(super_type const &that) const { diff --git a/lib/ts/string_view.h b/lib/ts/string_view.h index fc74cd5..c18dad3 100644 --- a/lib/ts/string_view.h +++ b/lib/ts/string_view.h @@ -834,11 +834,6 @@ private: }; // operators for basic_string_view<> -// this has a c++11 compat version and a c++14/17 version that uses enable_if_t and some newer stuff to reduce the code -// Ideally we use the old version for c++11 compilers, newer version for c++14 compiler. For c++17 we should not need this file -// as we can use the builtin version then -#if __cplusplus < 201402 - //////////////////////////// // == template <typename _Type, typename _Traits> @@ -1034,177 +1029,6 @@ operator>=(char const *const lhs, basic_string_view<_Type, _Traits> const rhs) return rhs.compare(lhs) >= 0; } -#else -///////////////////////////////////////////////// -// this form is more functional than the above case which only deals with char* and std::string -// this form deal with convertable type correctly as is less code :) - -//////////////////////////// -// == -template <typename _Type, typename _Traits> -constexpr bool -operator==(const basic_string_view<_Type, _Traits> lhs, const basic_string_view<_Type, _Traits> rhs) noexcept -{ - return lhs._equal(rhs); -} - -// user conversion for stuff like std::string or char*, literals - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator==(_OtherType &&lhs, const basic_string_view<_Type, _Traits> rhs) noexcept( - noexcept(basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs)))) -{ - return rhs._equal(std::forward<_OtherType>(lhs)); -} - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator==(const basic_string_view<_Type, _Traits> lhs, - _OtherType &&rhs) noexcept(noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(rhs))))) -{ - return lhs._equal(std::forward<_OtherType>(rhs)); -} - -/////////////////////////////// -// != -template <typename _Type, typename _Traits> -constexpr bool -operator!=(const basic_string_view<_Type, _Traits> lhs, const basic_string_view<_Type, _Traits> rhs) noexcept -{ - return !lhs._equal(rhs); -} - -// user conversion for stuff like std::string or char*, literals -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator!=(_OtherType &&lhs, const basic_string_view<_Type, _Traits> rhs) noexcept( - noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs))))) -{ - return !rhs._equal(std::forward<_OtherType>(lhs)); -} - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator!=(const basic_string_view<_Type, _Traits> lhs, - _OtherType &&rhs) noexcept(noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(rhs))))) -{ - return !lhs._equal(std::forward<_OtherType>(rhs)); -} - -/////////////////////////////// -// < -template <typename _Type, typename _Traits> -constexpr bool -operator<(const basic_string_view<_Type, _Traits> lhs, const basic_string_view<_Type, _Traits> rhs) noexcept -{ - return lhs.compare(rhs) < 0; -} - -// user conversion for stuff like std::string or char*, literals -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator<(_OtherType &&lhs, const basic_string_view<_Type, _Traits> rhs) noexcept( - noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs))))) -{ // less-than compare objects convertible to basic_string_view instances - return basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs)).compare(rhs) < 0; -} - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator<(const basic_string_view<_Type, _Traits> lhs, - _OtherType &&rhs) noexcept(noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(rhs))))) -{ - return lhs.compare(std::forward<_OtherType>(rhs)) < 0; -} - -/////////////////////////////// -// > -template <typename _Type, typename _Traits> -constexpr bool -operator>(const basic_string_view<_Type, _Traits> lhs, const basic_string_view<_Type, _Traits> rhs) noexcept -{ - return lhs.compare(rhs) > 0; -} -// user conversion for stuff like std::string or char*, literals -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator>(_OtherType &&lhs, const basic_string_view<_Type, _Traits> rhs) noexcept( - noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs))))) -{ - return basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs)).compare(rhs) > 0; -} - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator>(const basic_string_view<_Type, _Traits> lhs, - _OtherType &&rhs) noexcept(noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(rhs))))) -{ - return lhs.compare(std::forward<_OtherType>(rhs)) > 0; -} - -/////////////////////////////// -// <= -template <typename _Type, typename _Traits> -constexpr bool -operator<=(const basic_string_view<_Type, _Traits> lhs, const basic_string_view<_Type, _Traits> rhs) noexcept -{ - return lhs.compare(rhs) <= 0; -} -// user conversion for stuff like std::string or char*, literals -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator<=(_OtherType &&lhs, const basic_string_view<_Type, _Traits> rhs) noexcept( - noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs))))) -{ - return basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs)).compare(rhs) <= 0; -} - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator<=(const basic_string_view<_Type, _Traits> lhs, - _OtherType &&rhs) noexcept(noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(rhs))))) -{ - return lhs.compare(std::forward<_OtherType>(rhs)) <= 0; -} - -/////////////////////////////// -// >= -template <typename _Type, typename _Traits> -constexpr bool -operator>=(const basic_string_view<_Type, _Traits> lhs, const basic_string_view<_Type, _Traits> rhs) noexcept -{ - return lhs.compare(rhs) >= 0; -} -// user conversion for stuff like std::string or char*, literals -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator>=(_OtherType &&lhs, const basic_string_view<_Type, _Traits> rhs) noexcept( - noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs))))) -{ - return basic_string_view<_Type, _Traits>(std::forward<_OtherType>(lhs)).compare(rhs) >= 0; -} - -template <typename _Type, typename _Traits, typename _OtherType, - typename = std::enable_if_t<std::is_convertible<_OtherType, basic_string_view<_Type, _Traits>>::value>> -constexpr bool -operator>=(const basic_string_view<_Type, _Traits> lhs, - _OtherType &&rhs) noexcept(noexcept((basic_string_view<_Type, _Traits>(std::forward<_OtherType>(rhs))))) -{ - return lhs.compare(std::forward<_OtherType>(rhs)) >= 0; -} -#endif // stream operator template <typename _Type, typename _Traits> -- To stop receiving notification emails like this one, please contact a...@apache.org.