|
Boost : |
From: Matt Comi (mattcomi_at_[hidden])
Date: 2005-11-24 10:38:06
Hi,
I've written a functor (primarily for use with a std::map<string, ?>)
that sorts numerically first and alphabetically second using
lexical_cast. It looks like this:
try
{
return lexical_cast<double>(lhs) < lexical_cast<double>(rhs);
}
catch (bad_lexical_cast&)
{
return lhs < rhs;
}
...and it's been working nicely so far. However on the Pocket PC,
each time an exception is raised by the lexical_cast, it takes about
a quarter of a second to move on to the catch. Not very nice when the
map is huge.
As far as I can tell, there is no way to say to ensure that a
lexical_cast is going to be valid until you actually perform it. I'm
hoping that I won't need to resort to duplicating the innards of
lexical_cast in order to implement this function on the Pocket PC.
Any ideas?
Thanks all,
Matt.
------------------------------------------------------------------------
--------
Big Bucket Amusement
http://members.iinet.net.au/~mattcomi/mt/bigbucket
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk