[string_algo] Case-insensitive keys in map with is_iless?

Am I supposed to be able to use boost::algorithm::is_iless (see http://www.boost.org/doc/html/boost/algorithm/is_iless.html) to create a map with case-insensitive keys? I wonder as either it is broken in VS2005 or I do something wrong: #include <boost/algorithm/string.hpp> #include <string> #include <map> int main() { std::map<std::string, int, boost::algorithm::is_iless> m; m["test"] = 1; } C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocale(583) : error C2440: 'type cast' : cannot convert from 'unsigned char' to 'std::basic_string<_Elem,_Traits,_Ax>' ... C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocale(561) : error C2440: 'type cast' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'unsigned char' The assignment causes the problem. If you use insert() you get the same compiler error. Without the assignment the code compiles fine. Boris

Hi, is_iless works with characters, not strings. So you cannot use it to compare std::string keys. Regards, Pavol Boris wrote:
Am I supposed to be able to use boost::algorithm::is_iless (see http://www.boost.org/doc/html/boost/algorithm/is_iless.html) to create a map with case-insensitive keys? I wonder as either it is broken in VS2005 or I do something wrong:
#include <boost/algorithm/string.hpp> #include <string> #include <map>
int main() { std::map<std::string, int, boost::algorithm::is_iless> m; m["test"] = 1; }
C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocale(583) : error C2440: 'type cast' : cannot convert from 'unsigned char' to 'std::basic_string<_Elem,_Traits,_Ax>' ... C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocale(561) : error C2440: 'type cast' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'unsigned char'
The assignment causes the problem. If you use insert() you get the same compiler error. Without the assignment the code compiles fine.
Boris
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Sun, 07 Oct 2007 15:02:21 +0300, Pavol Droba <droba@topmail.sk> wrote:
is_iless works with characters, not strings. So you cannot use it to compare std::string keys.
Thanks for your reply! Is there anything else in the string algorithm library I could use? Otherwise I have to create my own comparison predicate which isn't really application-specific though (that's why I had thought to find it in a general purpose library like Boost). Boris
[...]

Hi, Boris wrote:
On Sun, 07 Oct 2007 15:02:21 +0300, Pavol Droba <droba@topmail.sk> wrote:
is_iless works with characters, not strings. So you cannot use it to compare std::string keys.
Thanks for your reply! Is there anything else in the string algorithm library I could use? Otherwise I have to create my own comparison predicate which isn't really application-specific though (that's why I had thought to find it in a general purpose library like Boost).
There is nothing that you can use directly for this purpose in the string_algo library now. Regards, Pavol.
participants (2)
-
Boris
-
Pavol Droba