| Index: base/strings/safe_sprintf.h
|
| diff --git a/base/strings/safe_sprintf.h b/base/strings/safe_sprintf.h
|
| index cbd7d0cd6435e202a4c427c0b70f51bbb72c8009..2d173202d3e78b52fcdb9b5a23b272f956b60c97 100644
|
| --- a/base/strings/safe_sprintf.h
|
| +++ b/base/strings/safe_sprintf.h
|
| @@ -218,220 +218,20 @@ BASE_EXPORT size_t GetSafeSPrintfSSizeMaxForTest();
|
|
|
| } // namespace internal
|
|
|
| -// TODO(markus): C++11 has a much more concise and readable solution for
|
| -// 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>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N,
|
| - class T0, class T1, class T2, class T3, class T4,
|
| - class T5, class T6, class T7, class T8, class T9>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2, class T3, class T4,
|
| - class T5, class T6, class T7, class T8>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6, T7 arg7, T8 arg8) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N,
|
| - class T0, class T1, class T2, class T3, class T4, class T5,
|
| - class T6, class T7, class T8>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6, T7 arg7, T8 arg8) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2, class T3, class T4, class T5,
|
| - class T6, class T7>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6, T7 arg7) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N,
|
| - class T0, class T1, class T2, class T3, class T4, class T5,
|
| - class T6, class T7>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6, T7 arg7) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2, class T3, class T4, class T5,
|
| - class T6>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4,
|
| - T5 arg5, T6 arg6) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N,
|
| - class T0, class T1, class T2, class T3, class T4, class T5,
|
| - class T6>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5,
|
| - T6 arg6) {
|
| - // 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[] = {
|
| - arg0, arg1, arg2, arg3, arg4, arg5, arg6
|
| - };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2, class T3, class T4, class T5>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) {
|
| - // 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[] = { arg0, arg1, arg2, arg3, arg4, arg5 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N,
|
| - class T0, class T1, class T2, class T3, class T4, class T5>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) {
|
| - // 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[] = { arg0, arg1, arg2, arg3, arg4, arg5 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2, class T3, class T4>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
|
| - // 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[] = { arg0, arg1, arg2, arg3, arg4 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N, class T0, class T1, class T2, class T3, class T4>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt, T0 arg0, T1 arg1,
|
| - T2 arg2, T3 arg3, T4 arg4) {
|
| - // 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[] = { arg0, arg1, arg2, arg3, arg4 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2, class T3>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
|
| - // 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[] = { arg0, arg1, arg2, arg3 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N, class T0, class T1, class T2, class T3>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
|
| - // 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[] = { arg0, arg1, arg2, arg3 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1, class T2>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt,
|
| - T0 arg0, T1 arg1, T2 arg2) {
|
| - // 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[] = { arg0, arg1, arg2 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N, class T0, class T1, class T2>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt, T0 arg0, T1 arg1,
|
| - T2 arg2) {
|
| - // 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[] = { arg0, arg1, arg2 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0, class T1>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt, T0 arg0, T1 arg1) {
|
| - // 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[] = { arg0, arg1 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<size_t N, class T0, class T1>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt, T0 arg0, T1 arg1) {
|
| - // 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[] = { arg0, arg1 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| -}
|
| -
|
| -template<class T0>
|
| -ssize_t SafeSNPrintf(char* buf, size_t N, const char* fmt, T0 arg0) {
|
| +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[] = { arg0 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| + const internal::Arg arg_array[] = { args... };
|
| + return internal::SafeSNPrintf(buf, N, fmt, arg_array, sizeof...(args));
|
| }
|
|
|
| -template<size_t N, class T0>
|
| -ssize_t SafeSPrintf(char (&buf)[N], const char* fmt, T0 arg0) {
|
| +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[] = { arg0 };
|
| - return internal::SafeSNPrintf(buf, N, fmt, arg_array, arraysize(arg_array));
|
| + const internal::Arg arg_array[] = { args... };
|
| + return internal::SafeSNPrintf(buf, N, fmt, arg_array, sizeof...(args));
|
| }
|
|
|
| // Fast-path when we don't actually need to substitute any arguments.
|
|
|