When compiling GNU clisp with clang++, I see this error:
.../gllib/string.h:1830:20: error: expected a qualified name after 'typename'
1830 | template <typename T> T strnul (T);
| ^
.../clisp.h:6891:12: note: expanded from macro 'T'
6891 | #define T (object{((oint)&symbol_tab_data.S_t+1UL), alloccount})
| ^
That's because clisp (rightfully) defines T as a macro.
This patch fixes it.
2026-10-11 Bruno Haible <[email protected]>
Make C++ templates more hygienic.
* lib/math.in.h (isfinite, isinf, isnan, signbit): Rename template
parameter T to _T_.
* lib/string.in.h (strnul, mbsstr_template, mbspcasecmp_template,
mbscasestr_template): Likewise.
* lib/unigbrk.in.h (u8_grapheme_next_template,
u16_grapheme_next_template, u32_grapheme_next_template,
u8_grapheme_prev_template, u16_grapheme_prev_template,
u32_grapheme_prev_template): Likewise.
* lib/unistr.in.h (u8_check_template, u16_check_template,
u32_check_template, u8_chr_template, u16_chr_template, u32_chr_template,
u8_next_template, u16_next_template, u32_next_template,
u8_prev_template, u16_prev_template, u32_prev_template,
u8_strchr_template, u16_strchr_template, u32_strchr_template,
u8_strrchr_template, u16_strrchr_template, u32_strrchr_template,
u8_strpbrk_template, u16_strpbrk_template, u32_strpbrk_template,
u8_strstr_template, u16_strstr_template, u32_strstr_template): Likewise.
* lib/xalloc.h (xrealloc, xreallocarray, xnrealloc, x2realloc,
x2nrealloc, xmemdup): Likewise.
* lib/stdcountof.in.h (struct _gl_array_type_test): Likewise. Rename
template parameter N to _N_.
diff --git a/lib/math.in.h b/lib/math.in.h
index b3ffab4e8b..063dd1b6ff 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -2467,7 +2467,7 @@ _GL_EXTERN_C int _gl_isfinitef (float x);
_GL_EXTERN_C int _gl_isfinited (double x);
_GL_EXTERN_C int _gl_isfinitel (long double x);
# ifdef __cplusplus
-template <typename T> int isfinite (T);
+template <typename _T_> int isfinite (_T_);
template <> inline int isfinite<float> (float x) { return _gl_isfinitef (x); }
template <> inline int isfinite<double> (double x) { return _gl_isfinited (x);
}
template <> inline int isfinite<long double> (long double x) { return
_gl_isfinitel (x); }
@@ -2509,7 +2509,7 @@ _GL_EXTERN_C int _gl_isinff (float x);
_GL_EXTERN_C int _gl_isinfd (double x);
_GL_EXTERN_C int _gl_isinfl (long double x);
# ifdef __cplusplus
-template <typename T> int isinf (T);
+template <typename _T_> int isinf (_T_);
template <> inline int isinf<float> (float x) { return _gl_isinff (x); }
template <> inline int isinf<double> (double x) { return _gl_isinfd (x); }
template <> inline int isinf<long double> (long double x) { return _gl_isinfl
(x); }
@@ -2651,7 +2651,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x)
_GL_ATTRIBUTE_CONST;
# endif
# ifdef __cplusplus
# undef isnan
-template <typename T> int isnan (T);
+template <typename _T_> int isnan (_T_);
template <> inline int isnan<float> (float x) { return _gl_isnanf (x); }
template <> inline int isnan<double> (double x) { return _gl_isnand (x); }
template <> inline int isnan<long double> (long double x) { return _gl_isnanl
(x); }
@@ -2665,7 +2665,7 @@ template <> inline int isnan<long double> (long double x)
{ return _gl_isnanl (x
# elif (__GNUC__ >= 4) || (__clang_major__ >= 4)
# ifdef __cplusplus
# undef isnan
-template <typename T> int isnan (T);
+template <typename _T_> int isnan (_T_);
template <> inline int isnan<float> (float x) { return __builtin_isnan (x); }
template <> inline int isnan<double> (double x) { return __builtin_isnan (x); }
template <> inline int isnan<long double> (long double x) { return
__builtin_isnan (x); }
@@ -2719,7 +2719,7 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
# undef signbit
/* GCC >= 4.0 and clang provide three built-ins for signbit. */
# if defined __cplusplus && !defined __clang__
-template <typename T> int signbit (T);
+template <typename _T_> int signbit (_T_);
template <> inline int signbit<float> (float x) { return __builtin_signbitf
(x); }
template <> inline int signbit<double> (double x) { return __builtin_signbit
(x); }
template <> inline int signbit<long double> (long double x) { return
__builtin_signbitl (x); }
@@ -2773,7 +2773,7 @@ _GL_EXTERN_C int _gl_signbitl (long double arg);
# endif
# endif
# if defined __cplusplus && !defined __clang__
-template <typename T> int signbit (T);
+template <typename _T_> int signbit (_T_);
template <> inline int signbit<float> (float x) { return _gl_signbitf (x); }
template <> inline int signbit<double> (double x) { return _gl_signbitd (x); }
template <> inline int signbit<long double> (long double x) { return
_gl_signbitl (x); }
diff --git a/lib/stdcountof.in.h b/lib/stdcountof.in.h
index c2de1adce8..59cd104f0b 100644
--- a/lib/stdcountof.in.h
+++ b/lib/stdcountof.in.h
@@ -70,17 +70,17 @@ template <int w>
# if 1
/* Use decltype. */
/* Default case. */
-template <typename T>
+template <typename _T_>
struct _gl_array_type_test { static const int is_array = -1; };
/* Unbounded arrays. */
-template <typename T>
- struct _gl_array_type_test<T[]> { static const int is_array = 1; };
+template <typename _T_>
+ struct _gl_array_type_test<_T_[]> { static const int is_array = 1; };
/* Bounded arrays. */
-template <typename T, size_t N>
- struct _gl_array_type_test<T[N]> { static const int is_array = 1; };
+template <typename _T_, size_t _N_>
+ struct _gl_array_type_test<_T_[_N_]> { static const int is_array = 1; };
/* String literals. */
-template <typename T, size_t N>
- struct _gl_array_type_test<T const (&)[N]> { static const int is_array = 1;
};
+template <typename _T_, size_t _N_>
+ struct _gl_array_type_test<_T_ const (&)[_N_]> { static const int is_array =
1; };
# define _gl_verify_is_array(...) \
sizeof
(_gl_verify_type<_gl_array_type_test<decltype(__VA_ARGS__)>::is_array>)
# else
@@ -88,17 +88,17 @@ template <typename T, size_t N>
Use sizeof to get a constant expression from an unknown type.
Note: This approach does not work for countof (((int[]) { a, b, c })). */
/* Default case. */
-template <typename T>
+template <typename _T_>
struct _gl_array_type_test { double large; };
/* Unbounded arrays. */
-template <typename T>
- struct _gl_array_type_test<T[]> { char small; };
+template <typename _T_>
+ struct _gl_array_type_test<_T_[]> { char small; };
/* Bounded arrays. */
-template <typename T, size_t N>
- struct _gl_array_type_test<T[N]> { char small; };
-/* The T& parameter is essential here: it prevents decay (array-to-pointer
+template <typename _T_, size_t _N_>
+ struct _gl_array_type_test<_T_[_N_]> { char small; };
+/* The _T_& parameter is essential here: it prevents decay (array-to-pointer
conversion). */
-template <typename T> _gl_array_type_test<T> _gl_array_type_test_helper(T&);
+template <typename _T_> _gl_array_type_test<_T_>
_gl_array_type_test_helper(_T_&);
# define _gl_verify_is_array(...) \
sizeof (_gl_verify_type<(sizeof (_gl_array_type_test_helper(__VA_ARGS__))
< sizeof (double) ? 1 : -1)>)
# endif
diff --git a/lib/string.in.h b/lib/string.in.h
index d05d983cd3..d2ede641d3 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1280,7 +1280,7 @@ _GL_STRNUL_INLINE const char *_gl_strnul (const char
*string)
# ifdef __cplusplus
extern "C++" { /* needed for AIX and Solaris 10 */
_GL_BEGIN_NAMESPACE
-template <typename T> T strnul (T);
+template <typename _T_> _T_ strnul (_T_);
template <> inline const char *strnul<const char *> (const char *s)
{ return _gl_strnul (s); }
template <> inline char *strnul< char *> ( char *s)
@@ -1418,8 +1418,8 @@ _GL_EXTERN_C char * mbsstr (const char *haystack, const
char *needle)
compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
extern "C++" { /* needed for AIX and Solaris 10 */
-template <typename T>
- T * mbsstr_template (T* haystack, const char *needle);
+template <typename _T_>
+ _T_ * mbsstr_template (_T_* haystack, const char *needle);
template <>
inline char * mbsstr_template (char *haystack, const char *needle)
{ return mbsstr (haystack, needle); }
@@ -1487,8 +1487,8 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string,
const char *prefix)
compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
extern "C++" { /* needed for AIX and Solaris 10 */
-template <typename T>
- T * mbspcasecmp_template (T* string, const char *prefix);
+template <typename _T_>
+ _T_ * mbspcasecmp_template (_T_* string, const char *prefix);
template <>
inline char * mbspcasecmp_template (char *string, const char *prefix)
{ return mbspcasecmp (string, prefix); }
@@ -1525,8 +1525,8 @@ _GL_EXTERN_C char * mbscasestr (const char *haystack,
const char *needle)
compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
extern "C++" { /* needed for AIX and Solaris 10 */
-template <typename T>
- T * mbscasestr_template (T* haystack, const char *needle);
+template <typename _T_>
+ _T_ * mbscasestr_template (_T_* haystack, const char *needle);
template <>
inline char * mbscasestr_template (char *haystack, const char *needle)
{ return mbscasestr (haystack, needle); }
diff --git a/lib/unigbrk.in.h b/lib/unigbrk.in.h
index f9966388fd..e143982cb2 100644
--- a/lib/unigbrk.in.h
+++ b/lib/unigbrk.in.h
@@ -117,8 +117,8 @@ extern const uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_grapheme_next_template (T* s, const uint8_t *end);
+template <typename _T_>
+ _T_ * u8_grapheme_next_template (_T_* s, const uint8_t *end);
template <>
inline uint8_t * u8_grapheme_next_template (uint8_t *s, const uint8_t *end)
{ return const_cast<uint8_t *>(u8_grapheme_next (s, end)); }
@@ -138,8 +138,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_grapheme_next_template (T* s, const uint16_t *end);
+template <typename _T_>
+ _T_ * u16_grapheme_next_template (_T_* s, const uint16_t *end);
template <>
inline uint16_t * u16_grapheme_next_template (uint16_t *s, const uint16_t
*end)
{ return const_cast<uint16_t *>(u16_grapheme_next (s, end)); }
@@ -159,8 +159,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_grapheme_next_template (T* s, const uint32_t *end);
+template <typename _T_>
+ _T_ * u32_grapheme_next_template (_T_* s, const uint32_t *end);
template <>
inline uint32_t * u32_grapheme_next_template (uint32_t *s, const uint32_t
*end)
{ return const_cast<uint32_t *>(u32_grapheme_next (s, end)); }
@@ -204,8 +204,8 @@ extern const uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_grapheme_prev_template (T* s, const uint8_t *start);
+template <typename _T_>
+ _T_ * u8_grapheme_prev_template (_T_* s, const uint8_t *start);
template <>
inline uint8_t * u8_grapheme_prev_template (uint8_t *s, const uint8_t *start)
{ return const_cast<uint8_t *>(u8_grapheme_prev (s, start)); }
@@ -225,8 +225,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_grapheme_prev_template (T* s, const uint16_t *start);
+template <typename _T_>
+ _T_ * u16_grapheme_prev_template (_T_* s, const uint16_t *start);
template <>
inline uint16_t * u16_grapheme_prev_template (uint16_t *s, const uint16_t
*start)
{ return const_cast<uint16_t *>(u16_grapheme_prev (s, start)); }
@@ -246,8 +246,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_grapheme_prev_template (T* s, const uint32_t *start);
+template <typename _T_>
+ _T_ * u32_grapheme_prev_template (_T_* s, const uint32_t *start);
template <>
inline uint32_t * u32_grapheme_prev_template (uint32_t *s, const uint32_t
*start)
{ return const_cast<uint32_t *>(u32_grapheme_prev (s, start)); }
diff --git a/lib/unistr.in.h b/lib/unistr.in.h
index e3cfd065fd..36baadde63 100644
--- a/lib/unistr.in.h
+++ b/lib/unistr.in.h
@@ -88,8 +88,8 @@ extern const uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_check_template (T* s, size_t n);
+template <typename _T_>
+ _T_ * u8_check_template (_T_* s, size_t n);
template <>
inline uint8_t * u8_check_template (uint8_t *s, size_t n)
{ return const_cast<uint8_t *>(u8_check (s, n)); }
@@ -109,8 +109,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_check_template (T* s, size_t n);
+template <typename _T_>
+ _T_ * u16_check_template (_T_* s, size_t n);
template <>
inline uint16_t * u16_check_template (uint16_t *s, size_t n)
{ return const_cast<uint16_t *>(u16_check (s, n)); }
@@ -130,8 +130,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_check_template (T* s, size_t n);
+template <typename _T_>
+ _T_ * u32_check_template (_T_* s, size_t n);
template <>
inline uint32_t * u32_check_template (uint32_t *s, size_t n)
{ return const_cast<uint32_t *>(u32_check (s, n)); }
@@ -525,8 +525,8 @@ extern uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_chr_template (T* str, size_t n, ucs4_t uc);
+template <typename _T_>
+ _T_ * u8_chr_template (_T_* str, size_t n, ucs4_t uc);
template <>
inline uint8_t * u8_chr_template (uint8_t *str, size_t n, ucs4_t uc)
{ return u8_chr (str, n, uc); }
@@ -546,8 +546,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_chr_template (T* str, size_t n, ucs4_t uc);
+template <typename _T_>
+ _T_ * u16_chr_template (_T_* str, size_t n, ucs4_t uc);
template <>
inline uint16_t * u16_chr_template (uint16_t *str, size_t n, ucs4_t uc)
{ return u16_chr (str, n, uc); }
@@ -567,8 +567,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_chr_template (T* str, size_t n, ucs4_t uc);
+template <typename _T_>
+ _T_ * u32_chr_template (_T_* str, size_t n, ucs4_t uc);
template <>
inline uint32_t * u32_chr_template (uint32_t *str, size_t n, ucs4_t uc)
{ return u32_chr (str, n, uc); }
@@ -654,8 +654,8 @@ extern const uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_next_template (ucs4_t *puc, T* s);
+template <typename _T_>
+ _T_ * u8_next_template (ucs4_t *puc, _T_* s);
template <>
inline uint8_t * u8_next_template (ucs4_t *puc, uint8_t *s)
{ return const_cast<uint8_t *>(u8_next (puc, s)); }
@@ -675,8 +675,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_next_template (ucs4_t *puc, T* s);
+template <typename _T_>
+ _T_ * u16_next_template (ucs4_t *puc, _T_* s);
template <>
inline uint16_t * u16_next_template (ucs4_t *puc, uint16_t *s)
{ return const_cast<uint16_t *>(u16_next (puc, s)); }
@@ -696,8 +696,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_next_template (ucs4_t *puc, T* s);
+template <typename _T_>
+ _T_ * u32_next_template (ucs4_t *puc, _T_* s);
template <>
inline uint32_t * u32_next_template (ucs4_t *puc, uint32_t *s)
{ return const_cast<uint32_t *>(u32_next (puc, s)); }
@@ -737,8 +737,8 @@ extern const uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_prev_template (ucs4_t *puc, T* s, const uint8_t *start);
+template <typename _T_>
+ _T_ * u8_prev_template (ucs4_t *puc, _T_* s, const uint8_t *start);
template <>
inline uint8_t * u8_prev_template (ucs4_t *puc, uint8_t *s, const uint8_t
*start)
{ return const_cast<uint8_t *>(u8_prev (puc, s, start)); }
@@ -758,8 +758,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_prev_template (ucs4_t *puc, T* s, const uint16_t *start);
+template <typename _T_>
+ _T_ * u16_prev_template (ucs4_t *puc, _T_* s, const uint16_t *start);
template <>
inline uint16_t * u16_prev_template (ucs4_t *puc, uint16_t *s, const
uint16_t *start)
{ return const_cast<uint16_t *>(u16_prev (puc, s, start)); }
@@ -779,8 +779,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_prev_template (ucs4_t *puc, T* s, const uint32_t *start);
+template <typename _T_>
+ _T_ * u32_prev_template (ucs4_t *puc, _T_* s, const uint32_t *start);
template <>
inline uint32_t * u32_prev_template (ucs4_t *puc, uint32_t *s, const
uint32_t *start)
{ return const_cast<uint32_t *>(u32_prev (puc, s, start)); }
@@ -956,8 +956,8 @@ extern uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_strchr_template (T* str, ucs4_t uc);
+template <typename _T_>
+ _T_ * u8_strchr_template (_T_* str, ucs4_t uc);
template <>
inline uint8_t * u8_strchr_template (uint8_t *str, ucs4_t uc)
{ return u8_strchr (str, uc); }
@@ -977,8 +977,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_strchr_template (T* str, ucs4_t uc);
+template <typename _T_>
+ _T_ * u16_strchr_template (_T_* str, ucs4_t uc);
template <>
inline uint16_t * u16_strchr_template (uint16_t *str, ucs4_t uc)
{ return u16_strchr (str, uc); }
@@ -998,8 +998,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_strchr_template (T* str, ucs4_t uc);
+template <typename _T_>
+ _T_ * u32_strchr_template (_T_* str, ucs4_t uc);
template <>
inline uint32_t * u32_strchr_template (uint32_t *str, ucs4_t uc)
{ return u32_strchr (str, uc); }
@@ -1041,8 +1041,8 @@ extern uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_strrchr_template (T* str, ucs4_t uc);
+template <typename _T_>
+ _T_ * u8_strrchr_template (_T_* str, ucs4_t uc);
template <>
inline uint8_t * u8_strrchr_template (uint8_t *str, ucs4_t uc)
{ return u8_strrchr (str, uc); }
@@ -1062,8 +1062,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_strrchr_template (T* str, ucs4_t uc);
+template <typename _T_>
+ _T_ * u16_strrchr_template (_T_* str, ucs4_t uc);
template <>
inline uint16_t * u16_strrchr_template (uint16_t *str, ucs4_t uc)
{ return u16_strrchr (str, uc); }
@@ -1083,8 +1083,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_strrchr_template (T* str, ucs4_t uc);
+template <typename _T_>
+ _T_ * u32_strrchr_template (_T_* str, ucs4_t uc);
template <>
inline uint32_t * u32_strrchr_template (uint32_t *str, ucs4_t uc)
{ return u32_strrchr (str, uc); }
@@ -1152,8 +1152,8 @@ extern uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_strpbrk_template (T* str, const uint8_t *accept);
+template <typename _T_>
+ _T_ * u8_strpbrk_template (_T_* str, const uint8_t *accept);
template <>
inline uint8_t * u8_strpbrk_template (uint8_t *str, const uint8_t *accept)
{ return u8_strpbrk (str, accept); }
@@ -1173,8 +1173,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_strpbrk_template (T* str, const uint16_t *accept);
+template <typename _T_>
+ _T_ * u16_strpbrk_template (_T_* str, const uint16_t *accept);
template <>
inline uint16_t * u16_strpbrk_template (uint16_t *str, const uint16_t
*accept)
{ return u16_strpbrk (str, accept); }
@@ -1194,8 +1194,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_strpbrk_template (T* str, const uint32_t *accept);
+template <typename _T_>
+ _T_ * u32_strpbrk_template (_T_* str, const uint32_t *accept);
template <>
inline uint32_t * u32_strpbrk_template (uint32_t *str, const uint32_t
*accept)
{ return u32_strpbrk (str, accept); }
@@ -1237,8 +1237,8 @@ extern uint32_t *
/* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers
want compiler warnings for 'const' related mistakes. */
# ifdef __cplusplus
-template <typename T>
- T * u8_strstr_template (T* haystack, const uint8_t *needle);
+template <typename _T_>
+ _T_ * u8_strstr_template (_T_* haystack, const uint8_t *needle);
template <>
inline uint8_t * u8_strstr_template (uint8_t *haystack, const uint8_t
*needle)
{ return u8_strstr (haystack, needle); }
@@ -1258,8 +1258,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u16_strstr_template (T* haystack, const uint16_t *needle);
+template <typename _T_>
+ _T_ * u16_strstr_template (_T_* haystack, const uint16_t *needle);
template <>
inline uint16_t * u16_strstr_template (uint16_t *haystack, const uint16_t
*needle)
{ return u16_strstr (haystack, needle); }
@@ -1279,8 +1279,8 @@ template <>
# endif
# endif
# ifdef __cplusplus
-template <typename T>
- T * u32_strstr_template (T* haystack, const uint32_t *needle);
+template <typename _T_>
+ _T_ * u32_strstr_template (_T_* haystack, const uint32_t *needle);
template <>
inline uint32_t * u32_strstr_template (uint32_t *haystack, const uint32_t
*needle)
{ return u32_strstr (haystack, needle); }
diff --git a/lib/xalloc.h b/lib/xalloc.h
index d3948270e8..a5d16d49bf 100644
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -170,41 +170,41 @@ char *xcharalloc (size_t n)
without a cast. Use templates to work around the problem when
possible. */
-template <typename T> inline T *
-xrealloc (T *p, size_t s)
+template <typename _T_> inline _T_ *
+xrealloc (_T_ *p, size_t s)
{
- return (T *) xrealloc ((void *) p, s);
+ return (_T_ *) xrealloc ((void *) p, s);
}
-template <typename T> inline T *
-xreallocarray (T *p, size_t n, size_t s)
+template <typename _T_> inline _T_ *
+xreallocarray (_T_ *p, size_t n, size_t s)
{
- return (T *) xreallocarray ((void *) p, n, s);
+ return (_T_ *) xreallocarray ((void *) p, n, s);
}
/* FIXME: Deprecate this in favor of xreallocarray? */
-template <typename T> inline T *
-xnrealloc (T *p, size_t n, size_t s)
+template <typename _T_> inline _T_ *
+xnrealloc (_T_ *p, size_t n, size_t s)
{
return xreallocarray (p, n, s);
}
-template <typename T> inline T *
-x2realloc (T *p, size_t *pn)
+template <typename _T_> inline _T_ *
+x2realloc (_T_ *p, size_t *pn)
{
- return (T *) x2realloc ((void *) p, pn);
+ return (_T_ *) x2realloc ((void *) p, pn);
}
-template <typename T> inline T *
-x2nrealloc (T *p, size_t *pn, size_t s)
+template <typename _T_> inline _T_ *
+x2nrealloc (_T_ *p, size_t *pn, size_t s)
{
- return (T *) x2nrealloc ((void *) p, pn, s);
+ return (_T_ *) x2nrealloc ((void *) p, pn, s);
}
-template <typename T> inline T *
-xmemdup (T const *p, size_t s)
+template <typename _T_> inline _T_ *
+xmemdup (_T_ const *p, size_t s)
{
- return (T *) xmemdup ((void const *) p, s);
+ return (_T_ *) xmemdup ((void const *) p, s);
}
#endif /* GNULIB_XALLOC && C++ */