Subject: Re: [boost] [Convert] std::isspace requires unsigned #28
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2017-03-21 01:49:09
On 21/03/2017 13:46, Vladimir Batov via Boost wrote:
> Thanks, Gavin, indeed I should have a dig in char_traits before
> re-inventing the wheel. Thanks.
There's also std::ctype<char/wchar_t>::is(), although the call syntax
for that seems a bit more cumbersome. Also at least according to
cppreference.com it hasn't been extended for the new 16-bit and 32-bit
C++11 char types. I don't know if that means anything.
> What about iswspace()? Does it have the same problem as std::isspace(),
> i.e. needs an explicit cast? Seems unlikely...
I think it's probably good practice to use char_traits<>::to_int_type()
for that too, since the parameter type is wint_t rather than wchar_t,
and that's the "right" way to do that conversion.
As Peter said in practice it probably wouldn't cause any bugs without
that since it would be weird for wchar_t to be signed, but as both the
sign and size of the type is implementation-defined it's not actually
illegal for that to be the case. (And you're even less likely to notice
on platforms where wchar_t is 32-bit or larger, but again that's
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk