[libcxx] r224292 - Implement LWG 2217 - operator==(sub_match, string) slices on embedded '\0's
Marshall Clow
mclow.lists at gmail.com
Mon Dec 15 15:57:56 PST 2014
Author: marshall
Date: Mon Dec 15 17:57:56 2014
New Revision: 224292
URL: http://llvm.org/viewvc/llvm-project?rev=224292&view=rev
Log:
Implement LWG 2217 - operator==(sub_match, string) slices on embedded '\0's
Modified:
libcxx/trunk/include/regex
libcxx/trunk/test/re/re.submatch/re.submatch.op/compare.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=224292&r1=224291&r2=224292&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Mon Dec 15 17:57:56 2014
@@ -4926,7 +4926,7 @@ bool
operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
const sub_match<_BiIter>& __y)
{
- return __y.compare(__x.c_str()) == 0;
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4944,7 +4944,7 @@ bool
operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
const sub_match<_BiIter>& __y)
{
- return __y.compare(__x.c_str()) > 0;
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4979,7 +4979,7 @@ bool
operator==(const sub_match<_BiIter>& __x,
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
{
- return __x.compare(__y.c_str()) == 0;
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4997,7 +4997,7 @@ bool
operator<(const sub_match<_BiIter>& __x,
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
{
- return __x.compare(__y.c_str()) < 0;
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
}
template <class _BiIter, class _ST, class _SA>
Modified: libcxx/trunk/test/re/re.submatch/re.submatch.op/compare.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.submatch/re.submatch.op/compare.pass.cpp?rev=224292&r1=224291&r2=224292&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.submatch/re.submatch.op/compare.pass.cpp (original)
+++ libcxx/trunk/test/re/re.submatch/re.submatch.op/compare.pass.cpp Mon Dec 15 17:57:56 2014
@@ -218,7 +218,7 @@
template <class CharT>
void
-test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y)
+test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y, bool doCStrTests = true)
{
typedef std::basic_string<CharT> string;
typedef std::sub_match<typename string::const_iterator> sub_match;
@@ -248,18 +248,20 @@ test(const std::basic_string<CharT>& x,
assert((sm1 > y) == (x > y));
assert((sm1 <= y) == (x <= y));
assert((sm1 >= y) == (x >= y));
- assert((x.c_str() == sm2) == (x == y));
- assert((x.c_str() != sm2) == (x != y));
- assert((x.c_str() < sm2) == (x < y));
- assert((x.c_str() > sm2) == (x > y));
- assert((x.c_str() <= sm2) == (x <= y));
- assert((x.c_str() >= sm2) == (x >= y));
- assert((sm1 == y.c_str()) == (x == y));
- assert((sm1 != y.c_str()) == (x != y));
- assert((sm1 < y.c_str()) == (x < y));
- assert((sm1 > y.c_str()) == (x > y));
- assert((sm1 <= y.c_str()) == (x <= y));
- assert((sm1 >= y.c_str()) == (x >= y));
+ if (doCStrTests) {
+ assert((x.c_str() == sm2) == (x == y));
+ assert((x.c_str() != sm2) == (x != y));
+ assert((x.c_str() < sm2) == (x < y));
+ assert((x.c_str() > sm2) == (x > y));
+ assert((x.c_str() <= sm2) == (x <= y));
+ assert((x.c_str() >= sm2) == (x >= y));
+ assert((sm1 == y.c_str()) == (x == y));
+ assert((sm1 != y.c_str()) == (x != y));
+ assert((sm1 < y.c_str()) == (x < y));
+ assert((sm1 > y.c_str()) == (x > y));
+ assert((sm1 <= y.c_str()) == (x <= y));
+ assert((sm1 >= y.c_str()) == (x >= y));
+ }
assert((x[0] == sm2) == (string(1, x[0]) == y));
assert((x[0] != sm2) == (string(1, x[0]) != y));
assert((x[0] < sm2) == (string(1, x[0]) < y));
@@ -280,4 +282,6 @@ int main()
test(std::string("1234"), std::string("123"));
test(std::wstring(L"123"), std::wstring(L"123"));
test(std::wstring(L"1234"), std::wstring(L"123"));
+ test(std::string("123\056", 6), std::string("123\056", 6), false);
+ test(std::wstring(L"123\056", 6), std::wstring(L"123\056", 6), false);
}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=224292&r1=224291&r2=224292&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Dec 15 17:57:56 2014
@@ -87,7 +87,7 @@
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2106">2106</td><td><code>move_iterator</code> wrapping iterators returning prvalues</td><td>Urbana</td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2129">2129</td><td>User specializations of <code>std::initializer_list</code></td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2212">2212</td><td><code>tuple_size</code> for <code>const pair</code> request <tuple> header</td><td>Urbana</td><td>Complete</td></tr>
- <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2217">2217</td><td><code>operator==(sub_match, string)</code> slices on embedded '\0's</td><td>Urbana</td><td></td></tr>
+ <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2217">2217</td><td><code>operator==(sub_match, string)</code> slices on embedded '\0's</td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2230">2230</td><td>"see below" for <code>initializer_list</code> constructors of unordered containers</td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2233">2233</td><td><code>bad_function_call::what()</code> unhelpful</td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2266">2266</td><td><code>vector</code> and <code>deque</code> have incorrect insert requirements</td><td>Urbana</td><td></td></tr>
More information about the cfe-commits
mailing list