namespace __detail
{
- enum class _RegexExecutorPolicy : int
- { _S_auto, _S_alternate };
+ enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate };
template<typename _BiIter, typename _Alloc,
typename _CharT, typename _TraitsT,
{ __lhs.swap(__rhs); }
- // [7.9] Class template sub_match
+ // C++11 28.9 [re.submatch] Class template sub_match
/**
* A sequence of characters matched by a particular marked sub-expression.
*
constexpr sub_match() noexcept : matched() { }
- /**
- * Gets the length of the matching sequence.
- */
+ /// Gets the length of the matching sequence.
difference_type
length() const noexcept
{ return this->matched ? std::distance(this->first, this->second) : 0; }
* from the unwary.
*/
operator string_type() const
- {
- return this->matched
- ? string_type(this->first, this->second)
- : string_type();
- }
+ { return str(); }
/**
* @brief Gets the matching sequence as a string.
*/
int
compare(const sub_match& __s) const
- { return this->str().compare(__s.str()); }
+ { return this->_M_str().compare(__s._M_str()); }
/**
+ * @{
* @brief Compares this sub_match to a string.
*
* @param __s A string to compare to this sub_match.
*/
int
compare(const string_type& __s) const
- { return this->str().compare(__s); }
+ { return this->_M_str().compare(__s); }
- /**
- * @brief Compares this sub_match to a C-style string.
- *
- * @param __s A C-style string to compare to this sub_match.
- *
- * @retval <0 this matched sequence will collate before @p __s.
- * @retval =0 this matched sequence is equivalent to @p __s.
- * @retval <0 this matched sequence will collate after @p __s.
- */
int
compare(const value_type* __s) const
- { return this->str().compare(__s); }
+ { return this->_M_str().compare(__s); }
+ // @}
+
+ // Non-standard, used by comparison operators
+ int
+ _M_compare(const value_type* __s, size_t __n) const
+ { return this->_M_str().compare({__s, __n}); }
+
+ private:
+ // Simplified basic_string_view for C++11
+ struct __string_view
+ {
+ using traits_type = typename string_type::traits_type;
+
+ __string_view() = default;
+
+ __string_view(const value_type* __s, size_t __n) noexcept
+ : _M_data(__s), _M_len(__n) { }
+
+ __string_view(const value_type* __s) noexcept
+ : _M_data(__s), _M_len(traits_type::length(__s)) { }
+
+ __string_view(const string_type& __s) noexcept
+ : _M_data(__s.data()), _M_len(__s.length()) { }
+
+ int
+ compare(__string_view __s) const noexcept
+ {
+ if (const size_t __n = std::min(_M_len, __s._M_len))
+ if (int __ret = traits_type::compare(_M_data, __s._M_data, __n))
+ return __ret;
+ const difference_type __diff = _M_len - __s._M_len;
+ if (__diff > std::numeric_limits<int>::max())
+ return std::numeric_limits<int>::max();
+ if (__diff < std::numeric_limits<int>::min())
+ return std::numeric_limits<int>::min();
+ return static_cast<int>(__diff);
+ }
+
+ private:
+ const value_type* _M_data = nullptr;
+ size_t _M_len = 0;
+ };
+
+ // Create a __string_view over the iterator range.
+ template<typename _Iter = _BiIter>
+ __enable_if_t<__detail::__is_contiguous_iter<_Iter>::value,
+ __string_view>
+ _M_str() const noexcept
+ {
+ if (this->matched)
+ if (auto __len = this->second - this->first)
+ return { std::__addressof(*this->first), __len };
+ return {};
+ }
+
+ // Create a temporary string that can be converted to __string_view.
+ template<typename _Iter = _BiIter>
+ __enable_if_t<!__detail::__is_contiguous_iter<_Iter>::value,
+ string_type>
+ _M_str() const
+ { return str(); }
};
operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) > 0; }
- // Alias for sub_match'd string.
+ // Alias for a basic_string that can be compared to a sub_match.
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
using __sub_match_string = basic_string<
typename iterator_traits<_Bi_iter>::value_type,
inline bool
operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
const sub_match<_Bi_iter>& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __rhs.compare(string_type(__lhs.data(), __lhs.size())) == 0;
- }
+ { return __rhs._M_compare(__lhs.data(), __lhs.size()) == 0; }
/**
* @brief Tests the inequivalence of a string and a regular expression
inline bool
operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
const sub_match<_Bi_iter>& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __rhs.compare(string_type(__lhs.data(), __lhs.size())) > 0;
- }
+ { return __rhs._M_compare(__lhs.data(), __lhs.size()) > 0; }
/**
* @brief Tests the ordering of a string and a regular expression submatch.
inline bool
operator==(const sub_match<_Bi_iter>& __lhs,
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __lhs.compare(string_type(__rhs.data(), __rhs.size())) == 0;
- }
+ { return __lhs._M_compare(__rhs.data(), __rhs.size()) == 0; }
/**
* @brief Tests the inequivalence of a regular expression submatch and a
* @param __rhs A string.
* @returns true if @a __lhs precedes @a __rhs, false otherwise.
*/
- template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool
operator<(const sub_match<_Bi_iter>& __lhs,
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __lhs.compare(string_type(__rhs.data(), __rhs.size())) < 0;
- }
+ { return __lhs._M_compare(__rhs.data(), __rhs.size()) < 0; }
/**
* @brief Tests the ordering of a regular expression submatch and a string.
* @param __rhs A string.
* @returns true if @a __lhs succeeds @a __rhs, false otherwise.
*/
- template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool
operator>(const sub_match<_Bi_iter>& __lhs,
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
* @param __rhs A string.
* @returns true if @a __lhs does not precede @a __rhs, false otherwise.
*/
- template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool
operator>=(const sub_match<_Bi_iter>& __lhs,
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
* @param __rhs A string.
* @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
*/
- template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool
operator<=(const sub_match<_Bi_iter>& __lhs,
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
/**
* @brief Tests the equivalence of a C string and a regular expression
* submatch.
- * @param __lhs A C string.
+ * @param __lhs A null-terminated string.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
*/
{ return __rhs.compare(__lhs) == 0; }
/**
- * @brief Tests the inequivalence of an iterator value and a regular
+ * @brief Tests the inequivalence of a C string and a regular
* expression submatch.
- * @param __lhs A regular expression submatch.
- * @param __rhs A string.
+ * @param __lhs A null-terminated string.
+ * @param __rhs A regular expression submatch.
* @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return !(__lhs == __rhs); }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a C string and a regular expression submatch.
+ * @param __lhs A null-terminated string.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs precedes @a __rhs, false otherwise.
*/
{ return __rhs.compare(__lhs) > 0; }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a C string and a regular expression submatch.
+ * @param __lhs A null-terminated string.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs succeeds @a __rhs, false otherwise.
*/
{ return __rhs < __lhs; }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a C string and a regular expression submatch.
+ * @param __lhs A null-terminated string.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs does not precede @a __rhs, false otherwise.
*/
{ return !(__lhs < __rhs); }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a C string and a regular expression submatch.
+ * @param __lhs A null-terminated string.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
*/
{ return !(__rhs < __lhs); }
/**
- * @brief Tests the equivalence of a regular expression submatch and a
+ * @brief Tests the equivalence of a regular expression submatch and a C
* string.
* @param __lhs A regular expression submatch.
- * @param __rhs A pointer to a string?
+ * @param __rhs A null-terminated string.
* @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
* @brief Tests the inequivalence of a regular expression submatch and a
* string.
* @param __lhs A regular expression submatch.
- * @param __rhs A pointer to a string.
+ * @param __rhs A null-terminated string.
* @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return !(__lhs == __rhs); }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a C string.
* @param __lhs A regular expression submatch.
- * @param __rhs A string.
+ * @param __rhs A null-terminated string.
* @returns true if @a __lhs precedes @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return __lhs.compare(__rhs) < 0; }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a C string.
* @param __lhs A regular expression submatch.
- * @param __rhs A string.
+ * @param __rhs A null-terminated string.
* @returns true if @a __lhs succeeds @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return __rhs < __lhs; }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a C string.
* @param __lhs A regular expression submatch.
- * @param __rhs A string.
+ * @param __rhs A null-terminated string.
* @returns true if @a __lhs does not precede @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return !(__lhs < __rhs); }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a C string.
* @param __lhs A regular expression submatch.
- * @param __rhs A string.
+ * @param __rhs A null-terminated string.
* @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return !(__rhs < __lhs); }
/**
- * @brief Tests the equivalence of a string and a regular expression
+ * @brief Tests the equivalence of a character and a regular expression
* submatch.
- * @param __lhs A string.
+ * @param __lhs A character.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
*/
inline bool
operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
const sub_match<_Bi_iter>& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __rhs.compare(string_type(1, __lhs)) == 0;
- }
+ { return __rhs._M_compare(std::__addressof(__lhs), 1) == 0; }
/**
- * @brief Tests the inequivalence of a string and a regular expression
+ * @brief Tests the inequivalence of a character and a regular expression
* submatch.
- * @param __lhs A string.
+ * @param __lhs A character.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
*/
{ return !(__lhs == __rhs); }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a character and a regular expression
+ * submatch.
+ * @param __lhs A character.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs precedes @a __rhs, false otherwise.
*/
inline bool
operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
const sub_match<_Bi_iter>& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __rhs.compare(string_type(1, __lhs)) > 0;
- }
+ { return __rhs._M_compare(std::__addressof(__lhs), 1) > 0; }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a character and a regular expression
+ * submatch.
+ * @param __lhs A character.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs succeeds @a __rhs, false otherwise.
*/
{ return __rhs < __lhs; }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a character and a regular expression
+ * submatch.
+ * @param __lhs A character.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs does not precede @a __rhs, false otherwise.
*/
{ return !(__lhs < __rhs); }
/**
- * @brief Tests the ordering of a string and a regular expression submatch.
- * @param __lhs A string.
+ * @brief Tests the ordering of a character and a regular expression
+ * submatch.
+ * @param __lhs A character.
* @param __rhs A regular expression submatch.
* @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
*/
/**
* @brief Tests the equivalence of a regular expression submatch and a
- * string.
+ * character.
* @param __lhs A regular expression submatch.
- * @param __rhs A const string reference.
+ * @param __rhs A character.
* @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
inline bool
operator==(const sub_match<_Bi_iter>& __lhs,
typename iterator_traits<_Bi_iter>::value_type const& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __lhs.compare(string_type(1, __rhs)) == 0;
- }
+ { return __lhs._M_compare(std::__addressof(__rhs), 1) == 0; }
/**
* @brief Tests the inequivalence of a regular expression submatch and a
- * string.
+ * character.
* @param __lhs A regular expression submatch.
- * @param __rhs A const string reference.
+ * @param __rhs A character.
* @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return !(__lhs == __rhs); }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a
+ * character.
* @param __lhs A regular expression submatch.
- * @param __rhs A const string reference.
+ * @param __rhs A character.
* @returns true if @a __lhs precedes @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
inline bool
operator<(const sub_match<_Bi_iter>& __lhs,
typename iterator_traits<_Bi_iter>::value_type const& __rhs)
- {
- typedef typename sub_match<_Bi_iter>::string_type string_type;
- return __lhs.compare(string_type(1, __rhs)) < 0;
- }
+ { return __lhs._M_compare(std::__addressof(__rhs), 1) < 0; }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a
+ * character.
* @param __lhs A regular expression submatch.
- * @param __rhs A const string reference.
+ * @param __rhs A character.
* @returns true if @a __lhs succeeds @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return __rhs < __lhs; }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a
+ * character.
* @param __lhs A regular expression submatch.
- * @param __rhs A const string reference.
+ * @param __rhs A character.
* @returns true if @a __lhs does not precede @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
{ return !(__lhs < __rhs); }
/**
- * @brief Tests the ordering of a regular expression submatch and a string.
+ * @brief Tests the ordering of a regular expression submatch and a
+ * character.
* @param __lhs A regular expression submatch.
- * @param __rhs A const string reference.
+ * @param __rhs A character.
* @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
*/
template<typename _Bi_iter>
--- /dev/null
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <regex>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::bidirectional_iterator_wrapper;
+
+template<typename C> struct traits : std::char_traits<C> { };
+
+void
+test01()
+{
+ const std::basic_string<char, traits<char>> s0, s1 = "1";
+ const std::ssub_match sm, sm2;
+
+ VERIFY( sm.compare(sm) == 0 );
+ VERIFY( sm.compare(sm2) == 0 );
+ VERIFY( sm.compare(sm.str()) == 0 );
+ VERIFY( sm.compare(sm.str().c_str()) == 0 );
+ VERIFY( sm.compare(sm2.str()) == 0 );
+ VERIFY( sm.compare(sm2.str().c_str()) == 0 );
+ VERIFY( sm.compare(std::string(s1.c_str())) == -1 );
+ VERIFY( sm.compare(s1.c_str()) == -1 );
+
+ VERIFY( sm == sm2 );
+ VERIFY( !(sm != sm2) );
+ VERIFY( !(sm < sm2) );
+ VERIFY( !(sm > sm2) );
+ VERIFY( sm <= sm2 );
+ VERIFY( sm >= sm2 );
+
+ VERIFY( sm == s0 );
+ VERIFY( !(sm != s0) );
+ VERIFY( !(sm < s0) );
+ VERIFY( !(sm > s0) );
+ VERIFY( sm <= s0 );
+ VERIFY( sm >= s0 );
+
+ VERIFY( s0 == sm );
+ VERIFY( !(s0 != sm) );
+ VERIFY( !(s0 < sm) );
+ VERIFY( !(s0 > sm) );
+ VERIFY( s0 <= sm );
+ VERIFY( s0 >= sm );
+
+ VERIFY( sm == s0.c_str() );
+ VERIFY( !(sm != s0.c_str()) );
+ VERIFY( !(sm < s0.c_str()) );
+ VERIFY( !(sm > s0.c_str()) );
+ VERIFY( sm <= s0.c_str() );
+ VERIFY( sm >= s0.c_str() );
+
+ VERIFY( s0.c_str() == sm );
+ VERIFY( !(s0.c_str() != sm) );
+ VERIFY( !(s0.c_str() < sm) );
+ VERIFY( !(s0.c_str() > sm) );
+ VERIFY( s0.c_str() <= sm );
+ VERIFY( s0.c_str() >= sm );
+
+ VERIFY( !(sm == s1) );
+ VERIFY( sm != s1 );
+ VERIFY( sm < s1 );
+ VERIFY( !(sm > s1) );
+ VERIFY( sm <= s1 );
+ VERIFY( !(sm >= s1) );
+
+ VERIFY( !(sm == s1.c_str()) );
+ VERIFY( sm != s1.c_str() );
+ VERIFY( sm < s1.c_str() );
+ VERIFY( !(sm > s1.c_str()) );
+ VERIFY( sm <= s1.c_str() );
+ VERIFY( !(sm >= s1.c_str()) );
+
+ VERIFY( !(s1.c_str() == sm) );
+ VERIFY( s1.c_str() != sm );
+ VERIFY( !(s1.c_str() < sm) );
+ VERIFY( s1.c_str() > sm );
+ VERIFY( !(s1.c_str() <= sm) );
+ VERIFY( s1.c_str() >= sm );
+
+ VERIFY( !(sm == s1[0]) );
+ VERIFY( sm != s1[0] );
+ VERIFY( sm < s1[0] );
+ VERIFY( !(sm > s1[0]) );
+ VERIFY( sm <= s1[0] );
+ VERIFY( !(sm >= s1[0]) );
+
+ VERIFY( !(s1[0] == sm) );
+ VERIFY( s1[0] != sm );
+ VERIFY( !(s1[0] < sm) );
+ VERIFY( s1[0] > sm );
+ VERIFY( !(s1[0] <= sm) );
+ VERIFY( s1[0] >= sm );
+}
+
+void
+test02()
+{
+ const std::basic_string<char, traits<char>> s0, s1 = "1";
+ std::csub_match sm;
+ const std::csub_match sm2;
+ const char c[] = "1";
+ sm.matched = true;
+ sm.first = c;
+ sm.second = c+1;
+
+ VERIFY( sm.compare(sm) == 0 );
+ VERIFY( sm.compare(sm2) == 1 );
+ VERIFY( sm.compare(sm.str()) == 0 );
+ VERIFY( sm.compare(sm.str().c_str()) == 0 );
+ VERIFY( sm.compare(sm2.str()) == 1 );
+ VERIFY( sm.compare(sm2.str().c_str()) == 1 );
+ VERIFY( sm.compare(std::string(s1.c_str())) == 0 );
+ VERIFY( sm.compare(s1.c_str()) == 0 );
+
+ VERIFY( !(sm == sm2) );
+ VERIFY( sm != sm2 );
+ VERIFY( !(sm < sm2) );
+ VERIFY( sm > sm2 );
+ VERIFY( !(sm <= sm2) );
+ VERIFY( sm >= sm2 );
+
+ VERIFY( !(sm2 == sm) );
+ VERIFY( sm2 != sm );
+ VERIFY( sm2 < sm );
+ VERIFY( !(sm2 > sm) );
+ VERIFY( sm2 <= sm );
+ VERIFY( !(sm2 >= sm) );
+
+ VERIFY( !(sm == s0) );
+ VERIFY( sm != s0 );
+ VERIFY( !(sm < s0) );
+ VERIFY( sm > s0 );
+ VERIFY( !(sm <= s0) );
+ VERIFY( sm >= s0 );
+
+ VERIFY( !(sm == s0.c_str()) );
+ VERIFY( sm != s0.c_str() );
+ VERIFY( !(sm < s0.c_str()) );
+ VERIFY( sm > s0.c_str() );
+ VERIFY( !(sm <= s0.c_str()) );
+ VERIFY( sm >= s0.c_str() );
+
+ VERIFY( !(s0.c_str() == sm) );
+ VERIFY( s0.c_str() != sm );
+ VERIFY( s0.c_str() < sm );
+ VERIFY( !(s0.c_str() > sm) );
+ VERIFY( s0.c_str() <= sm );
+ VERIFY( !(s0.c_str() >= sm) );
+
+ VERIFY( s1 == sm );
+ VERIFY( !(s1 != sm) );
+ VERIFY( !(s1 < sm) );
+ VERIFY( !(s1 > sm) );
+ VERIFY( s1 <= sm );
+ VERIFY( s1 >= sm );
+
+ VERIFY( sm == s1.c_str() );
+ VERIFY( !(sm != s1.c_str()) );
+ VERIFY( !(sm < s1.c_str()) );
+ VERIFY( !(sm > s1.c_str()) );
+ VERIFY( sm <= s1.c_str() );
+ VERIFY( sm >= s1.c_str() );
+
+ VERIFY( s1.c_str() == sm );
+ VERIFY( !(s1.c_str() != sm) );
+ VERIFY( !(s1.c_str() < sm) );
+ VERIFY( !(s1.c_str() > sm) );
+ VERIFY( s1.c_str() <= sm );
+ VERIFY( s1.c_str() >= sm );
+
+ VERIFY( sm == s1[0] );
+ VERIFY( !(sm != s1[0]) );
+ VERIFY( !(sm < s1[0]) );
+ VERIFY( !(sm > s1[0]) );
+ VERIFY( sm <= s1[0] );
+ VERIFY( sm >= s1[0] );
+
+ VERIFY( s1[0] == sm );
+ VERIFY( !(s1[0] != sm) );
+ VERIFY( !(s1[0] < sm) );
+ VERIFY( !(s1[0] > sm) );
+ VERIFY( s1[0] <= sm );
+ VERIFY( s1[0] >= sm );
+}
+
+void
+test03()
+{
+ const std::basic_string<char, traits<char>> s0, s1 = "1";
+ const char c[] = "1";
+ test_container<const char, bidirectional_iterator_wrapper> tc(c, c+1);
+ std::sub_match<bidirectional_iterator_wrapper<const char>> sm;
+ const std::sub_match<bidirectional_iterator_wrapper<const char>> sm2;
+ sm.matched = true;
+ sm.first = tc.begin();
+ sm.second = tc.end();
+
+ VERIFY( sm.compare(sm) == 0 );
+ VERIFY( sm.compare(sm2) == 1 );
+ VERIFY( sm.compare(sm.str()) == 0 );
+ VERIFY( sm.compare(sm.str().c_str()) == 0 );
+ VERIFY( sm.compare(sm2.str()) == 1 );
+ VERIFY( sm.compare(sm2.str().c_str()) == 1 );
+ VERIFY( sm.compare(std::string(s1.c_str())) == 0 );
+ VERIFY( sm.compare(s1.c_str()) == 0 );
+
+ VERIFY( !(sm == sm2) );
+ VERIFY( sm != sm2 );
+ VERIFY( !(sm < sm2) );
+ VERIFY( sm > sm2 );
+ VERIFY( !(sm <= sm2) );
+ VERIFY( sm >= sm2 );
+
+ VERIFY( !(sm2 == sm) );
+ VERIFY( sm2 != sm );
+ VERIFY( sm2 < sm );
+ VERIFY( !(sm2 > sm) );
+ VERIFY( sm2 <= sm );
+ VERIFY( !(sm2 >= sm) );
+
+ VERIFY( !(sm == s0) );
+ VERIFY( sm != s0 );
+ VERIFY( !(sm < s0) );
+ VERIFY( sm > s0 );
+ VERIFY( !(sm <= s0) );
+ VERIFY( sm >= s0 );
+
+ VERIFY( !(sm == s0.c_str()) );
+ VERIFY( sm != s0.c_str() );
+ VERIFY( !(sm < s0.c_str()) );
+ VERIFY( sm > s0.c_str() );
+ VERIFY( !(sm <= s0.c_str()) );
+ VERIFY( sm >= s0.c_str() );
+
+ VERIFY( !(s0.c_str() == sm) );
+ VERIFY( s0.c_str() != sm );
+ VERIFY( s0.c_str() < sm );
+ VERIFY( !(s0.c_str() > sm) );
+ VERIFY( s0.c_str() <= sm );
+ VERIFY( !(s0.c_str() >= sm) );
+
+ VERIFY( s1 == sm );
+ VERIFY( !(s1 != sm) );
+ VERIFY( !(s1 < sm) );
+ VERIFY( !(s1 > sm) );
+ VERIFY( s1 <= sm );
+ VERIFY( s1 >= sm );
+
+ VERIFY( sm == s1.c_str() );
+ VERIFY( !(sm != s1.c_str()) );
+ VERIFY( !(sm < s1.c_str()) );
+ VERIFY( !(sm > s1.c_str()) );
+ VERIFY( sm <= s1.c_str() );
+ VERIFY( sm >= s1.c_str() );
+
+ VERIFY( s1.c_str() == sm );
+ VERIFY( !(s1.c_str() != sm) );
+ VERIFY( !(s1.c_str() < sm) );
+ VERIFY( !(s1.c_str() > sm) );
+ VERIFY( s1.c_str() <= sm );
+ VERIFY( s1.c_str() >= sm );
+
+ VERIFY( sm == s1[0] );
+ VERIFY( !(sm != s1[0]) );
+ VERIFY( !(sm < s1[0]) );
+ VERIFY( !(sm > s1[0]) );
+ VERIFY( sm <= s1[0] );
+ VERIFY( sm >= s1[0] );
+
+ VERIFY( s1[0] == sm );
+ VERIFY( !(s1[0] != sm) );
+ VERIFY( !(s1[0] < sm) );
+ VERIFY( !(s1[0] > sm) );
+ VERIFY( s1[0] <= sm );
+ VERIFY( s1[0] >= sm );
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+}