Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: base/strings/safe_sprintf.h

Issue 102993006: Remove C++11 specific version of SafeSNPrintf() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update unit test as well Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/strings/safe_sprintf_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/safe_sprintf.h
diff --git a/base/strings/safe_sprintf.h b/base/strings/safe_sprintf.h
index a1be047955c191fc07ce1835c062f8c45cbfe19e..c9ee717375386f8fc666fa04403c210eafefb3f2 100644
--- a/base/strings/safe_sprintf.h
+++ b/base/strings/safe_sprintf.h
@@ -104,8 +104,6 @@ typedef long ssize_t;
// like SafeSPrintf(buf, "%p %d", 1, 2) results in "%p 2"). See above for
// the use of RAW_CHECK() in debug builds, though.
//
-// The pre-C++11 version cannot handle more than ten arguments.
-//
// Basic example:
// char buf[20];
// base::strings::SafeSPrintf(buf, "The answer: %2d", 42);
@@ -190,29 +188,8 @@ BASE_EXPORT size_t GetSafeSPrintfSSizeMaxForTest();
} // namespace internal
-#if __cplusplus >= 201103 // C++11
-
-template<typename... Args>
-ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt, Args... args) {
- // Use Arg() object to record type information and then copy arguments to an
- // array to make it easier to iterate over them.
- const internal::Arg arg_array[] = { args... };
- return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
-}
-
-template<size_t N, typename... Args>
-ssize_t SafeSPrintf(char (&buf)[N], const char* fmt, Args... args) {
- // Use Arg() object to record type information and then copy arguments to an
- // array to make it easier to iterate over them.
- const internal::Arg arg_array[] = { args... };
- return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
-}
-
-#else // Pre-C++11
-
// TODO(markus): C++11 has a much more concise and readable solution for
-// expressing what we are doing here. Delete the fall-back code for older
-// compilers as soon as we have fully switched to C++11.
+// expressing what we are doing here.
template<class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
@@ -426,7 +403,6 @@ ssize_t SafeSPrintf(char (&buf)[N], const char* fmt, T0 arg0) {
const internal::Arg arg_array[] = { arg0 };
return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
}
-#endif
// Fast-path when we don't actually need to substitute any arguments.
BASE_EXPORT ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt);
« no previous file with comments | « no previous file | base/strings/safe_sprintf_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698