Ticket #8021: boost-8021a.diff

File boost-8021a.diff, 1.2 KB (added by kailoran@…, 10 years ago)

C++11-only patch to fix the warning

  • boost/property_tree/detail/ptree_utils.hpp

     
    6666        return result;
    6767    }
    6868
     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
    6984    // Naively convert string to narrow character type
    7085    template<class Ch>
    7186    std::string narrow(const Ch *text)
     
    7388        std::string result;
    7489        while (*text)
    7590        {
    76             if (*text < 0 || *text > (std::numeric_limits<char>::max)())
     91            if (value_outside_narrow(*text))
    7792                result += '*';
    7893            else
    7994                result += char(*text);