From b520289660c5f81ff31510ba01d68256ddffcecf Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 9 Oct 2021 20:12:32 +0300 Subject: [PATCH] Test std::pmr::string in sv_eq_test --- include/boost/core/string_view.hpp | 24 ++++++++++++------------ test/sv_eq_test.cpp | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/include/boost/core/string_view.hpp b/include/boost/core/string_view.hpp index 4272b69..246e79c 100644 --- a/include/boost/core/string_view.hpp +++ b/include/boost/core/string_view.hpp @@ -1073,62 +1073,62 @@ public: // against std::string - BOOST_CXX14_CONSTEXPR friend bool operator==( basic_string_view sv1, std::basic_string const& sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator==( basic_string_view sv1, std::basic_string, A> const& sv2 ) BOOST_NOEXCEPT { return sv1.compare( sv2 ) == 0; } - BOOST_CXX14_CONSTEXPR friend bool operator==( std::basic_string const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator==( std::basic_string, A> const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT { return sv2.compare( sv1 ) == 0; } - BOOST_CXX14_CONSTEXPR friend bool operator!=( basic_string_view sv1, std::basic_string const& sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator!=( basic_string_view sv1, std::basic_string, A> const& sv2 ) BOOST_NOEXCEPT { return sv1.compare( sv2 ) != 0; } - BOOST_CXX14_CONSTEXPR friend bool operator!=( std::basic_string const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator!=( std::basic_string, A> const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT { return sv2.compare( sv1 ) != 0; } - BOOST_CXX14_CONSTEXPR friend bool operator<( basic_string_view sv1, std::basic_string const& sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator<( basic_string_view sv1, std::basic_string, A> const& sv2 ) BOOST_NOEXCEPT { return sv1.compare( sv2 ) < 0; } - BOOST_CXX14_CONSTEXPR friend bool operator<( std::basic_string const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator<( std::basic_string, A> const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT { return sv2.compare( sv1 ) > 0; } - BOOST_CXX14_CONSTEXPR friend bool operator<=( basic_string_view sv1, std::basic_string const& sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator<=( basic_string_view sv1, std::basic_string, A> const& sv2 ) BOOST_NOEXCEPT { return sv1.compare( sv2 ) <= 0; } - BOOST_CXX14_CONSTEXPR friend bool operator<=( std::basic_string const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator<=( std::basic_string, A> const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT { return sv2.compare( sv1 ) >= 0; } - BOOST_CXX14_CONSTEXPR friend bool operator>( basic_string_view sv1, std::basic_string const& sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator>( basic_string_view sv1, std::basic_string, A> const& sv2 ) BOOST_NOEXCEPT { return sv1.compare( sv2 ) > 0; } - BOOST_CXX14_CONSTEXPR friend bool operator>( std::basic_string const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator>( std::basic_string, A> const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT { return sv2.compare( sv1 ) < 0; } - BOOST_CXX14_CONSTEXPR friend bool operator>=( basic_string_view sv1, std::basic_string const& sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator>=( basic_string_view sv1, std::basic_string, A> const& sv2 ) BOOST_NOEXCEPT { return sv1.compare( sv2 ) >= 0; } - BOOST_CXX14_CONSTEXPR friend bool operator>=( std::basic_string const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT + template BOOST_CXX14_CONSTEXPR friend bool operator>=( std::basic_string, A> const& sv1, basic_string_view sv2 ) BOOST_NOEXCEPT { return sv2.compare( sv1 ) <= 0; } diff --git a/test/sv_eq_test.cpp b/test/sv_eq_test.cpp index 3511a14..ea48831 100644 --- a/test/sv_eq_test.cpp +++ b/test/sv_eq_test.cpp @@ -8,6 +8,9 @@ #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) # include #endif +#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE) +# include +#endif #define TEST_EQ(x, y) \ BOOST_TEST_EQ(x, y); \ @@ -85,6 +88,24 @@ int main() BOOST_TEST_NE( sv3, std::string_view( "122" ) ); BOOST_TEST_NE( std::string_view( "122" ), sv3 ); +#endif + +#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE) + + using pmr_string = std::basic_string, std::pmr::polymorphic_allocator>; + + BOOST_TEST_EQ( sv1, pmr_string( "" ) ); + BOOST_TEST_EQ( pmr_string( "" ), sv1 ); + + BOOST_TEST_NE( sv1, pmr_string( "1" ) ); + BOOST_TEST_NE( pmr_string( "1" ), sv1 ); + + BOOST_TEST_EQ( sv3, pmr_string( "123" ) ); + BOOST_TEST_EQ( pmr_string( "123" ), sv3 ); + + BOOST_TEST_NE( sv3, pmr_string( "122" ) ); + BOOST_TEST_NE( pmr_string( "122" ), sv3 ); + #endif }