Cleaned up the const_cast mess a little.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 16 Apr 2013 01:38:08 -0400
changeset 7076 1666f7a7494e
parent 7075 f4a3c5a68119
child 7077 f8e3dcefed59
Cleaned up the const_cast mess a little.
include/SDL_stdinc.h
--- a/include/SDL_stdinc.h	Wed Apr 17 11:45:50 2013 -0400
+++ b/include/SDL_stdinc.h	Tue Apr 16 01:38:08 2013 -0400
@@ -93,9 +93,11 @@
 #ifdef __cplusplus
 #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
 #define SDL_static_cast(type, expression) static_cast<type>(expression)
+#define SDL_const_cast(type, expression) const_cast<type>(expression)
 #else
 #define SDL_reinterpret_cast(type, expression) ((type)(expression))
 #define SDL_static_cast(type, expression) ((type)(expression))
+#define SDL_const_cast(type, expression) ((type)(expression))
 #endif
 /*@}*//*Cast operators*/
 
@@ -502,49 +504,25 @@
 
 extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
 #ifdef HAVE_STRCHR
-SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
-#ifdef __cplusplus
-return const_cast<char*>(strchr(str, c));
-#else
-return (char*)strchr(str, c);
-#endif
-}
+SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
 #define SDL_strchr SDL_strchr_inline
 #elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
-SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
+SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
 #define SDL_strchr SDL_strchr_inline
 #endif
 
 extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
 #ifdef HAVE_STRRCHR
-SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
-#ifdef __cplusplus
-return const_cast<char*>(strrchr(str, c));
-#else
-return (char*)strrchr(str, c);
-#endif
-}
+SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
 #define SDL_strrchr SDL_strrchr_inline
 #elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
-SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
-#ifdef __cplusplus
-return const_cast<char*>(rindex(str, c));
-#else
-return (char*)rindex(str, c);
-#endif
-}
+SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
 #define SDL_strrchr SDL_strrchr_inline
 #endif
 
 extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
 #ifdef HAVE_STRSTR
-SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
-#ifdef __cplusplus
-return const_cast<char*>(strstr(haystack, needle));
-#else
-return (char*)strstr(haystack, needle);
-#endif
-}
+SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
 #define SDL_strstr SDL_strstr_inline
 #endif