Thread View: comp.std.c++
1 messages
1 total messages
Started by Herb Sutter
Wed, 23 Aug 1995 15:25
Re: Usage of STL maps with pointers to member functions
Author: Herb Sutter
Date: Wed, 23 Aug 1995 15:25
Date: Wed, 23 Aug 1995 15:25
30 lines
1554 bytes
1554 bytes
admin@rzaix13.uni-hamburg.de (Bernd Eggink) wrote:
>Gabriel Sanchez Gutierrez (gsg@sema.es) wrote:
>> #include <iostream.h>
>> #include <map.h>
>
>> typedef char* string;
^^^^^^^^^^^^^^^^^^^^
Very bad.
>You are comparing pointers instead of strings. Add
>
> struct less<string>
> {
> bool operator()(string a, string b) { return strcmp(a, b) < 0; }
> };
>
>and it will work.
Typedef'ing "char*" to "string" is dangerous and misleading, since "string"
already exists in the language. In fact, removing the typedef should solve
the original problem and make the program work properly!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herb Sutter 2228 Urwin, Ste 102 voice (416) 618-0184
Connected Object Solutions Oakville ON Canada L6L 2T2 fax (905) 847-6019
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads