From c1b6178278b59fb7a9769c5084ec1c41e5e5859f Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Wed, 12 Oct 2005 15:03:16 +0000 Subject: [PATCH] Implement wx_truncate_cast for VC++ 7.1 and later git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35896 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 2e933f17d0..18a82b4c68 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -309,9 +309,24 @@ typedef int wxWindowID; } #define wx_truncate_cast(t, x) wx_truncate_cast_impl(x) -#else /* !__INTELC__ */ + +#elif defined(__cplusplus) && defined(__VISUALC__) && __VISUALC__ >= 1310 + template + inline T wx_truncate_cast_impl(X x) + { + #pragma warning(push) + /* conversion from 'X' to 'T', possible loss of data */ + #pragma warning(disable: 4267) + + return x; + + #pragma warning(pop) + } + + #define wx_truncate_cast(t, x) wx_truncate_cast_impl(x) +#else #define wx_truncate_cast(t, x) ((t)(x)) -#endif /* __INTELC__/!__INTELC__ */ +#endif /* for consistency with wxStatic/DynamicCast defined in wx/object.h */ #define wxConstCast(obj, className) wx_const_cast(className *, obj) -- 2.45.2