public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* help
@ 2024-04-08 15:53 Jicheng Tang
  0 siblings, 0 replies; 5+ messages in thread
From: Jicheng Tang @ 2024-04-08 15:53 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Help.
@ 2004-08-30 11:18 help
  0 siblings, 0 replies; 5+ messages in thread
From: help @ 2004-08-30 11:18 UTC (permalink / raw)
  To: gcc-bugs

Hello:
  I am Chinese.  I have some trouble.
Can you help me ?
I have paypal account ,but i can't get paypal money in China.
Do you have paypal ? If you have ,i want to send money to you ,then you return the money to me by western union.
I give you some fee.   For example: I send u $500, i will give you $50,you return $450USD.
 
 
Are you agree?
 
If you agree with me ,please contact me , my icq is : 277851088

Thank you

I wait your reply.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: help
@ 1998-02-19 14:17 Max Lawson
  0 siblings, 0 replies; 5+ messages in thread
From: Max Lawson @ 1998-02-19 14:17 UTC (permalink / raw)
  To: egcs-bugs, ian, jhpb

Thanx all for your answers


> This needs to be something like:
> 
> hash_map< const char*, int,hash<const char*>,equal_to<string> > hm;
> 
> The problem you're encountering is that while I the hash function is presumably
> finding the right string in the hash map, the equality comparison you're using
> -- equals_to<const char*> -- is only comparing the ADDRESS of the
> string-pointers, not the strings they point to.
> --
> Ian Haggard  ||  ian@shellus.com (work)  ||  IanHaggard@juno.com (home)
> GNU/Linux -- "Oh, no, Mr Bill!" || #define employer_opinion !my_opinion
> 

You get it :-). But, instead of using the equal_to<string> construct I'm
going to provide a new one in order to avoid temporaries (a wrapper to 
strcmp()).


Regards, Max


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: help
  1998-02-18 17:26 help Max Lawson
@ 1998-02-19  7:34 ` Ian Haggard
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Haggard @ 1998-02-19  7:34 UTC (permalink / raw)
  To: Max Lawson, egcs-bugs

Here's the problem:

> hash_map<const char*, int> hm;

This needs to be something like:

hash_map< const char*, int,hash<const char*>,equal_to<string> > hm;

The problem you're encountering is that while I the hash function is presumably
finding the right string in the hash map, the equality comparison you're using
-- equals_to<const char*> -- is only comparing the ADDRESS of the
string-pointers, not the strings they point to.
--
Ian Haggard  ||  ian@shellus.com (work)  ||  IanHaggard@juno.com (home)
GNU/Linux -- "Oh, no, Mr Bill!" || #define employer_opinion !my_opinion


^ permalink raw reply	[flat|nested] 5+ messages in thread

* help
@ 1998-02-18 17:26 Max Lawson
  1998-02-19  7:34 ` help Ian Haggard
  0 siblings, 1 reply; 5+ messages in thread
From: Max Lawson @ 1998-02-18 17:26 UTC (permalink / raw)
  To: egcs-bugs

	Good morning, 

I'm re-posting this message since it does'nt reach
the list.

Bye, Max


 /*
  Hi !

  I need your help: the foolowing testcase drives me crazy !
  I want to use a hash_map with  strings as the key type. 
  And, to take advantage of the builtin string_hash_function, I've 
  decided to use c-type string internally. But it doesn't work and I 
  *cannot* locate the problem! Here are the compilation and 
  the execution steps:

  
$ g++ bug.cc
In file included from /usr/local/egcs-980205/include/g++/hash_map:31,
                 from bug.cc:17:
/usr/local/egcs-980205/include/g++/stl_hashtable.h:150: warning: decimal integer constant is so large that it is unsigned
/usr/local/egcs-980205/include/g++/stl_hashtable.h:150: warning: decimal integer constant is so large that it is unsigned
$ a.out 
s1 == s0
'hello': 1
'hello': 0


  I should have obtained :

$ a.out 
s1 == s0
'hello': 1
'hello': 1


  Did I miss something ? 

  Thanx in advance, Max

  P.S. the compiler warnings are wrong since the prime numbers in 
  stl_hashtable.h are of type "const unsigned long". my 0.02$


 */

#include <string>
#include <iostream.h>
#include <hash_map>

hash_map<const char*, int> hm;

void show(const string& str) 
{ 
  cerr << "\'" << str.c_str() << "\': " << hm[str.c_str()] << "\n"; 
}

int main()
{
  string s0("hello");
  string s1("hello");

  cerr << (s1 == s0 ? "s1 == s0" : "s1 != s0") << endl;


  hm[s0.c_str()] = 1;

  show(s0);

  show(s1);

  return 0;
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-08 15:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08 15:53 help Jicheng Tang
  -- strict thread matches above, loose matches on Subject: below --
2004-08-30 11:18 Help help
1998-02-19 14:17 help Max Lawson
1998-02-18 17:26 help Max Lawson
1998-02-19  7:34 ` help Ian Haggard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).