stlab.adobe.com Adobe Systems Incorporated

windows_cast.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /****************************************************************************************************/
00008 
00009 #ifndef ADOBE_WINCAST_HPP
00010 #define ADOBE_WINCAST_HPP
00011 
00012 #include <adobe/config.hpp>
00013 
00014 /****************************************************************************************************/
00015 
00016 namespace hackery {
00017 
00018 /****************************************************************************************************/
00019 
00020 template <typename T, typename U>
00021 inline T cast(U u)
00022 {
00023     // REVISIT (fbrereto) : This function circumvents an issue where MSVC won't allow for the casting
00024     //                      of a primitive of smaller type to one of larger type. Please use sparingly,
00025     //                      but when this type of cast must be made use this function so it can be
00026     //                      pulled out easily.
00027 
00028 // because it might be cygwin
00029 #if ADOBE_PLATFORM_WIN
00030     #pragma warning ( push )
00031     #pragma warning ( disable : 4311 ) // typecast pointer truncation from type to type
00032     #pragma warning ( disable : 4312 ) // typecast conversion from type to type of greater size
00033     #pragma warning ( disable : 4800 ) // conversion to true/false performance warning
00034 #endif
00035 
00036     return (T)(u);
00037 
00038 // because it might be cygwin
00039 #if ADOBE_PLATFORM_WIN
00040     #pragma warning ( pop )
00041 #endif
00042 }
00043 
00044 /****************************************************************************************************/
00045     
00046 } // namespace hackery
00047 
00048 /****************************************************************************************************/
00049 
00050 #endif
00051 
00052 /****************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google