From c6fe8cafc3539c903f55cc96da4b7d12c4b9a1d5 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 8 Oct 2011 14:36:16 +0000 Subject: [PATCH] Fix match_results::begin() is off by one git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@141494 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/regex | 4 ++-- test/re/re.results/re.results.acc/begin_end.pass.cpp | 4 ++-- test/re/re.results/re.results.acc/cbegin_cend.pass.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/regex b/include/regex index 5e195696..760f4eb9 100644 --- a/include/regex +++ b/include/regex @@ -5210,11 +5210,11 @@ public: const_reference suffix() const {return __suffix_;} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin() + 1;} + const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();} _LIBCPP_INLINE_VISIBILITY const_iterator end() const {return __matches_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin() + 1;} + const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();} _LIBCPP_INLINE_VISIBILITY const_iterator cend() const {return __matches_.end();} diff --git a/test/re/re.results/re.results.acc/begin_end.pass.cpp b/test/re/re.results/re.results.acc/begin_end.pass.cpp index e71dcacf..80c06f29 100644 --- a/test/re/re.results/re.results.acc/begin_end.pass.cpp +++ b/test/re/re.results/re.results.acc/begin_end.pass.cpp @@ -27,8 +27,8 @@ test() std::match_results::const_iterator i = m.begin(); std::match_results::const_iterator e = m.end(); - assert(e - i == m.size() - 1); - for (int j = 1; i != e; ++i, ++j) + assert(e - i == m.size()); + for (int j = 0; i != e; ++i, ++j) assert(*i == m[j]); } diff --git a/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp b/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp index f56fe009..a983c8af 100644 --- a/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp +++ b/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp @@ -27,8 +27,8 @@ test() std::match_results::const_iterator i = m.cbegin(); std::match_results::const_iterator e = m.cend(); - assert(e - i == m.size() - 1); - for (int j = 1; i != e; ++i, ++j) + assert(e - i == m.size()); + for (int j = 0; i != e; ++i, ++j) assert(*i == m[j]); }