File indexing completed on 2025-01-31 10:02:34
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_SPIRIT_X3_CAST_CHAR_NOVEMBER_10_2006_0907AM)
0009 #define BOOST_SPIRIT_X3_CAST_CHAR_NOVEMBER_10_2006_0907AM
0010
0011 #include <boost/type_traits/is_signed.hpp>
0012 #include <boost/type_traits/make_unsigned.hpp>
0013 #include <boost/type_traits/make_signed.hpp>
0014
0015 namespace boost { namespace spirit { namespace x3 { namespace detail
0016 {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 template <typename TargetChar, typename SourceChar>
0027 TargetChar cast_char(SourceChar ch)
0028 {
0029 #if defined(_MSC_VER)
0030 # pragma warning(push)
0031 # pragma warning(disable: 4127)
0032 #endif
0033 if (is_signed<TargetChar>::value != is_signed<SourceChar>::value)
0034 {
0035 if (is_signed<SourceChar>::value)
0036 {
0037
0038 typedef typename make_unsigned<SourceChar>::type USourceChar;
0039 return TargetChar(USourceChar(ch));
0040 }
0041 else
0042 {
0043
0044 typedef typename make_signed<SourceChar>::type SSourceChar;
0045 return TargetChar(SSourceChar(ch));
0046 }
0047 }
0048 else
0049 {
0050
0051 return TargetChar(ch);
0052 }
0053 #if defined(_MSC_VER)
0054 # pragma warning(pop)
0055 #endif
0056 }
0057 }}}}
0058
0059 #endif
0060
0061