Ticket #4649: 4649-mtc.patch

File 4649-mtc.patch, 2.0 KB (added by Marshall Clow, 12 years ago)
  • token_functions.hpp

     
    209209  // Assuming that the conditional will always get optimized out in the function
    210210  // implementations, argument types are not a problem since both forms of character classifiers
    211211  // expect an int.
     212   
     213#if !defined(BOOST_NO_CWCTYPE)
     214  template<typename traits, int N>
     215  struct traits_extension_details : public traits {
     216    typedef typename traits::char_type char_type;
     217    static bool isspace(char_type c)
     218    {
     219       return std::iswspace(c) != 0;
     220    }
     221    static bool ispunct(char_type c)
     222    {
     223       return std::iswpunct(c) != 0;
     224    }
     225  };
     226
     227  template<typename traits>
     228  struct traits_extension_details<traits, 1> : public traits {
     229    typedef typename traits::char_type char_type;
     230    static bool isspace(char_type c)
     231    {
     232       return std::isspace(c) != 0;
     233    }
     234    static bool ispunct(char_type c)
     235    {
     236       return std::ispunct(c) != 0;
     237    }
     238  };
     239#endif
     240
     241   
    212242  // In case there is no cwctype header, we implement the checks manually.
    213243  // We make use of the fact that the tested categories should fit in ASCII.
    214244  template<typename traits>
     
    217247    static bool isspace(char_type c)
    218248    {
    219249#if !defined(BOOST_NO_CWCTYPE)
    220       if (sizeof(char_type) == 1)
    221         return std::isspace(static_cast<int>(c)) != 0;
    222       else
    223         return std::iswspace(static_cast<std::wint_t>(c)) != 0;
     250      return traits_extension_details<traits, sizeof(char_type)>::isspace(c);
    224251#else
    225252      return static_cast< unsigned >(c) <= 255 && std::isspace(c) != 0;
    226253#endif
     
    230257    {
    231258#if !defined(BOOST_NO_CWCTYPE)
    232259      if (sizeof(char_type) == 1)
    233         return std::ispunct(static_cast<int>(c)) != 0;
     260        return traits_extension_details<traits, sizeof(char_type)>::ispunct(c);
    234261      else
    235262        return std::iswpunct(static_cast<std::wint_t>(c)) != 0;
    236263#else