Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::string - case insensitive?

Reply
Thread Tools

std::string - case insensitive?

 
 
Gernot Frisch
Guest
Posts: n/a
 
      03-17-2005
hi,

what would be the easiest (fastest to write) way to abbrevate from
std::string and make it case insensitive for use with std::map?
Overwrite c'tors and = operator, or overwrite <,>, and compare
functions?

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-17-2005
"Gernot Frisch" <(E-Mail Removed)> wrote...
> what would be the easiest (fastest to write) way to abbrevate from
> std::string and make it case insensitive for use with std::map?
> Overwrite c'tors and = operator, or overwrite <,>, and compare functions?


No, the easiest would be to provide your own comparator when
constructing your map. See the third argument for the 'map' template.

std::map<std::string, MyStoredType, MyCaseInsentitiveCompare> myMap;


V


 
Reply With Quote
 
 
 
 
rajkumar@hotmail.com
Guest
Posts: n/a
 
      03-17-2005
You dont need to over write <

map just needs you to define < operator. == > are not needed

You can pass a custom comparion operator to the map constructor in
which case it will ignore the string < operator.
Look the third argument map takes it defaults to std::less
Raj

 
Reply With Quote
 
Richard Herring
Guest
Posts: n/a
 
      03-18-2005
In message <(E-Mail Removed)>, Gernot Frisch
<(E-Mail Removed)> writes
>hi,
>
>what would be the easiest (fastest to write) way to abbrevate from
>std::string and make it case insensitive for use with std::map?
>Overwrite c'tors and = operator, or overwrite <,>, and compare
>functions?
>

If you want a complete case-insensitive string class, rather than just a
hack for std::map, there's another approach: use std::basic_string with
an appropriate traits class.

See http://www.gotw.ca/gotw/029.htm

--
Richard Herring
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
case insensitive find on case sensitive stl map benhoefer@gmail.com C++ 1 04-06-2007 08:42 PM
lower case to upper case Janice C Programming 17 12-14-2004 02:35 PM
how to case select with case-insensitive string ? Tee ASP .Net 3 06-23-2004 07:40 PM
Possible to turn on/off cookieless sessions dynamically on a case by case basis at run-time? Steve Franks ASP .Net 2 06-10-2004 02:04 PM
Scorsese Collection: Keep case vs Snap case Ray DVD Video 0 05-30-2004 04:04 AM



Advertisments