Ticket #8021: boost-8021a.diff
File boost-8021a.diff, 1.2 KB (added by , 10 years ago) |
---|
-
boost/property_tree/detail/ptree_utils.hpp
66 66 return result; 67 67 } 68 68 69 // Helper to avoid gcc comparison-always-false (-Wtype-limits) warning 70 template<class Ch> 71 typename std::enable_if<std::is_unsigned<Ch>::value, bool>::type 72 value_outside_narrow(const Ch& ch) 73 { 74 return ch > (std::numeric_limits<char>::max)(); 75 } 76 77 template<class Ch> 78 typename std::enable_if<!std::is_unsigned<Ch>::value, bool>::type 79 value_outside_narrow(const Ch& ch) 80 { 81 return ch < 0 || ch > (std::numeric_limits<char>::max)(); 82 } 83 69 84 // Naively convert string to narrow character type 70 85 template<class Ch> 71 86 std::string narrow(const Ch *text) … … 73 88 std::string result; 74 89 while (*text) 75 90 { 76 if ( *text < 0 || *text > (std::numeric_limits<char>::max)())91 if (value_outside_narrow(*text)) 77 92 result += '*'; 78 93 else 79 94 result += char(*text);