Assuming I have this function (it's not complete):
template<typename InputType, typename OutputIterator>
void to_utf8(InputType input, OutputIterator result)
{
// trivial conversion
if (input < (1 << 7)) {
*result = input; ++result;
}else {
*result = ((input >6) | 0xc0); ++result;
*result = ((input & 0x3f) | 0x80); ++result;
}
}
Everything works fine if InputType is "unsigned" but it could not work if
InputType is "signed".
This problem can be generalized in every template function where a numbering
compare is applied.
template<typename InputType>
bool is_valid_xml_range(InputType input)
{
if ( ( input >= 0x20 ) && ( input <= 0xD7FF ) )
return true;
else
return false;
}
Is there a way to use always the "unsigned" representation, e.g.
template<typename InputType>
bool is_valid_xml_range(InputType input)
{
UnsignedInputType uinput = input;
if ( ( uinput >= 0x20 ) && ( uinput <= 0xD7FF ) )
return true;
else
return false;
}
Regards,
Fabio