From a824e5035cb57b32a7804d5619e120c0e898ae81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Thu, 25 Dec 2014 10:24:07 +0800 Subject: [PATCH] bug fix --- TinySTL/String.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/TinySTL/String.h b/TinySTL/String.h index 68ed74c..f4b7db5 100644 --- a/TinySTL/String.h +++ b/TinySTL/String.h @@ -628,14 +628,22 @@ namespace TinySTL{ return compare_aux(pos, len, s, 0, n); } size_t string::find_first_of(const string& str, size_t pos) const{ - return find_first_of(str.begin(), pos, size() - pos); + //return find_first_of(str.begin(), pos, size() - pos); + return find_first_of(str.begin(), pos, str.size()); } size_t string::find_first_of(const char* s, size_t pos) const{ - return find_first_of(s, pos, size() - pos); + //return find_first_of(s, pos, size() - pos); + return find_first_of(s, pos, strlen(s)); } size_t string::find_first_of(const char* s, size_t pos, size_t n) const{ - for (size_t i = pos; i != pos + n; ++i){ - if (isContained((*this)[i], s, s + strlen(s))) + //for (size_t i = pos; i != pos + n; ++i){ + // if (isContained((*this)[i], s, s + strlen(s))) + // return i; + //} + //bug fix + //2014.12.25 + for (size_t i = pos; i != size(); ++i){ + if (isContained((*this)[i], s, s + n)) return i; } return npos;