On 2017-03-21 11:16, Vladimir Batov via Boost wrote:
... Damn confused.
WAS: std::isspace(ch); THEN: std::isspace(static_cast<unsigned char>(ch));
THEN I realized I needed wchar_t support and therefore needed also std::iswspace(). So, for such a seemingly trivial thing I ended up with the following ugliness:
namespace cnv { template<typename char_type> struct char_test {};
template<> struct char_test<char> { static bool is_space(char ch) { return std::isspace(static_cast<unsigned char>(ch)); } }; template<> struct char_test
{ static bool is_space(wchar_t ch) { return std::iswspace(ch); } }; template<typename char_type> bool is_space(char_type ch) { return char_test ::is_space(ch); } } That raises two questions.
1) Is it really the only way to go or I went senile or fell behind language-wise? 2) What about std::iswspace? Does it also need static_cast?
OK, I guess function specifications are much shorter. Phew. Still. What do I do with No.2? template<typename char_type> bool is_space(char_type); template<> bool is_space (unsigned char c)... template<> bool is_space (char c)... template<> bool is_space (unsigned wchar_t c)... template<> bool is_space (wchar_t c)...