On Sat, 16 Jul 2005 18:46:33 +0200, Pavol Droba
I am aware that string_algo has an if_iequal functor. Is there also an equivalent for a less-than comparison? I have to compare strings ignoring the case but taking locales into account. Right now I'm calling boost::algorithm::to_lower on two copies of the original strings. I'm not so sure if this is very efficient when I'm comparing thousands of strings.
Here's the functor as it is now:
struct FileLessNameA : std::binary_function
{ bool operator() (const File& lhs, const File& rhs) const { std::string path1( lhs.get_name().c_str() ); std::string path2( rhs.get_name().c_str() ); boost::algorithm::to_lower( path1 ); boost::algorithm::to_lower( path2 ); return path1 < path2; } };
There is no such a function in string_algo lib. But you can easily use std::lexicographical_compare.
There is a variant with a custom comparison predicate. For that you can use boost::is_iequal defined in boost/algorithm/string/compare.hpp.
But is_iequal only tests for equality, it doesn't provide an ordering of the characters. He's looking for something like is_iless, which I think would be a nice addition too string_algo. -- Be seeing you.