diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-24 18:16:16 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-24 18:16:16 +0000 |
commit | eb591bf80f3019ff8da33e9222dd7a92bcf675f9 (patch) | |
tree | 242b07dba6b7e39f4cdd3a14a14c90d99d6108f7 | |
parent | 17c1461e33117455a3b0287fa95dbb5a5d1ab7d8 (diff) | |
download | chromium_src-eb591bf80f3019ff8da33e9222dd7a92bcf675f9.zip chromium_src-eb591bf80f3019ff8da33e9222dd7a92bcf675f9.tar.gz chromium_src-eb591bf80f3019ff8da33e9222dd7a92bcf675f9.tar.bz2 |
Use a correct templatized WriteInto for all string types
Review URL: http://codereview.chromium.org/53014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12372 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/string_util.h | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/base/string_util.h b/base/string_util.h index 7f86009..ca1fc05 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -490,19 +490,11 @@ void StringAppendV(std::wstring* dst, const wchar_t* format, va_list ap); // the string's buffer with nulls. I call it to change the length of the // string (needed because writing directly to the buffer doesn't do this). // Perhaps there's a constant-time way to change the string's length. -template <class char_type> -inline char_type* WriteInto( - std::basic_string<char_type, std::char_traits<char_type>, - std::allocator<char_type> >* str, - size_t length_including_null) { - str->reserve(length_including_null); - str->resize(length_including_null - 1); - return &((*str)[0]); -} - -inline char16* WriteInto(string16* str, size_t length_including_null) { - str->reserve(length_including_null); - str->resize(length_including_null - 1); +template <class string_type> +inline typename string_type::value_type* WriteInto(string_type* str, + size_t length_with_null) { + str->reserve(length_with_null); + str->resize(length_with_null - 1); return &((*str)[0]); } |