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);} 3 6995
"Gernot Frisch" <Me@Privacy.net> 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
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
In message <39*************@individual.net>, Gernot Frisch
<Me@Privacy.net> 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Espen Ruud Schultz |
last post by:
Lets say I have a char pointer and an std::string. Is it possible to get a
pointer to the std::string's "content" so that the char pointer can point to
the same text? And vice versa; can I give...
|
by: Angus Leeming |
last post by:
Hello,
Could someone explain to me why the Standard conveners chose to typedef
std::string rather than derive it from std::basic_string<char, ...>?
The result of course is that it is...
|
by: Jim Langston |
last post by:
Is there any builtin lowercase std::string compare? Right now I'm doing
this:
if ( _stricmp( AmmoTypeText.c_str(), "GunBullet" ) == 0 )
AmmoType = Item_Ammo_GunBullet;
Is there anything the...
|
by: mr_sorcerer |
last post by:
Hi!
I just found something interesting.
I mean what do you think about this:
char *p = 0;
std::string str = p;
Why std::string doesn't check null pointers?
|
by: probstm |
last post by:
I am using a message handler class that implements amongst others:
static void message ( std::string aHeader,
std::string aMessage,
int aTimeout = 0,
MessageType aFlag =
MSG_Information );
...
|
by: Jacek Dziedzic |
last post by:
Hi!
I need a routine like:
std::string nth_word(const std::string &s, unsigned int n) {
// return n-th word from the string, n is 0-based
// if 's' contains too few words, return ""
//...
|
by: Mosfet |
last post by:
Hi,
what is the most efficient way of doing a case insensitive comparison ?
I am trying to write a universal String class and I am stuck with the
case insensitive part :
TCHAR is a char in...
|
by: Bala2508 |
last post by:
Hi,
I have a C++ application that extensively uses std::string and
std::ostringstream in somewhat similar manner as below
std::string msgHeader;
msgHeader = "<";
msgHeader += a;
msgHeader...
|
by: tech |
last post by:
Hi, I need a function to specify a match pattern including using
wildcard characters as below
to find chars in a std::string.
The match pattern can contain the wildcard characters "*" and "?",...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |