|
Boost : |
From: Alexander Nasonov (alnsn-boost_at_[hidden])
Date: 2002-03-26 08:41:02
I have a little class digit_traits that might be interesting to boost.
It's just replacement for nonportable char (or wchar_t) to digit conversion:
char seven = '7';
int digit = seven - '0';
assert(digit == 7);
With digit_traits this conversion is:
char seven = '7';
int digit = digit_traits<char>::digit2int(seven);
assert(digit == 7);
For charsets with non-continuous digit characters range it should work just fine
(although I don't know about such charsets and didn't find the requirement in
Standard for digit characters to be continuous) .
Links to source code are:
digit_traits.hpp:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cpp-experiment/cpp-experiment/include/
cppexp/digit_traits.hpp?rev=1.2
identity.hpp:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cpp-experiment/cpp-experiment/include/
cppexp/identity.hpp?rev=1.1
----------------------
Alexander Nasonov
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk