Boost logo

Boost :

From: Matt Comi (mattcomi_at_[hidden])
Date: 2005-11-24 10:38:06


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:

         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,


Big Bucket Amusement

Boost list run by bdawes at, gregod at, cpdaniel at, john at