public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/13342] New: hash_map doesn't support std::string keys
@ 2003-12-07 17:32 kgirard at connect dot carleton dot ca
  2003-12-07 17:37 ` [Bug libstdc++/13342] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kgirard at connect dot carleton dot ca @ 2003-12-07 17:32 UTC (permalink / raw)
  To: gcc-bugs

Overview Description:
 The GNU extension hash_map class doesn't support using std::strings for keys. I
think it should support a common class like std::string

Steps to Reproduce:

  I compiled this:

  #include <string>
  #include <ext/hash_map>

  using namespace std;
  using namespace __gnu_cxx;

  int main()
  {
    hash_map<string, int> hm;
    hm["January"] = 30;
    return 0;
  }

  with the following:

  g++ hashtest.cpp


Actual Results:

  Gcc gave me the following error

  ...<snip>....
  /usr/include/c++/3.3/ext/stl_hashtable.h:514: error: no match for call to `(
     const __gnu_cxx::hash<std::string>) (const std::basic_string<char,
     std::char_traits<char>, std::allocator<char> >&)'


Expected Results:

  Successful Compile


Solution:
 
Add

  template<> struct hash<std::string>                                          
            
  {                                                                            
              
    size_t operator()(const std::string& __x) const 
    { 
      return __stl_hash_string(__x.c_str()); 
    }                                                                          
              
  };                                                                           
              

to ext/stl_hash_fun.h

-- 
           Summary: hash_map doesn't support std::string keys
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kgirard at connect dot carleton dot ca
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
@ 2003-12-07 17:37 ` pinskia at gcc dot gnu dot org
  2003-12-07 17:59 ` kgirard at connect dot carleton dot ca
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-07 17:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-07 17:37 -------
You can do your own hash on std::string and you do not have to depend on libstdc++ to provide 
support for hash_map.  Point is if you want this in sumbit a patch to gcc-patches@gcc.gnu.org and 
libstdc++@, make sure that the patch is against the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-12-07 17:37:14
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
  2003-12-07 17:37 ` [Bug libstdc++/13342] " pinskia at gcc dot gnu dot org
@ 2003-12-07 17:59 ` kgirard at connect dot carleton dot ca
  2003-12-07 18:49 ` gdr at integrable-solutions dot net
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kgirard at connect dot carleton dot ca @ 2003-12-07 17:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kgirard at connect dot carleton dot ca  2003-12-07 17:59 -------
I currently supply my own std::string hash in my projects but I though it would
be nice have it built into libstdc++ since std::string's should be very common.
 I didn't know how the whole gcc/libstdc++ patch thing worked sorry.  I will do
a check out of the mainline and submit a patch and see what happens ;)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
  2003-12-07 17:37 ` [Bug libstdc++/13342] " pinskia at gcc dot gnu dot org
  2003-12-07 17:59 ` kgirard at connect dot carleton dot ca
@ 2003-12-07 18:49 ` gdr at integrable-solutions dot net
  2003-12-09  3:08 ` bkoz at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-12-07 18:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2003-12-07 18:49 -------
Subject: Re:  hash_map doesn't support std::string keys

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

|              Status|UNCONFIRMED                 |NEW

I would prefer this PR not be open needlessly.  There are hihgh
chances that we get something different (see library TRs) for hash
maps and this one receives  an unmaintained status.

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
                   ` (2 preceding siblings ...)
  2003-12-07 18:49 ` gdr at integrable-solutions dot net
@ 2003-12-09  3:08 ` bkoz at gcc dot gnu dot org
  2004-01-21 20:45 ` pcarlini at suse dot de
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2003-12-09  3:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at gcc dot gnu dot org  2003-12-09 03:08 -------

FYI we use hash strings in abi_check.cc. To do this, we do:

namespace __gnu_cxx
{
  using namespace std;
 
  template<>
    struct hash<string>
    {
      size_t operator()(const string& s) const
      {
        const collate<char>& c = use_facet<collate<char> >(locale::classic());
        return c.hash(s.c_str(), s.c_str() + s.size());
      }
    };
}

This is my preferred solution for hashing strings.

-benjamin

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
                   ` (3 preceding siblings ...)
  2003-12-09  3:08 ` bkoz at gcc dot gnu dot org
@ 2004-01-21 20:45 ` pcarlini at suse dot de
  2004-03-20 19:08 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2004-01-21 20:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-01-21 20:44 -------
*** Bug 13794 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wyderski at ii dot uni dot
                   |                            |wroc dot pl


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
                   ` (4 preceding siblings ...)
  2004-01-21 20:45 ` pcarlini at suse dot de
@ 2004-03-20 19:08 ` pcarlini at suse dot de
  2004-03-20 19:09 ` pcarlini at suse dot de
  2004-03-24 13:16 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2004-03-20 19:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-03-20 19:08 -------
I guess we can safely close this one...

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
                   ` (5 preceding siblings ...)
  2004-03-20 19:08 ` pcarlini at suse dot de
@ 2004-03-20 19:09 ` pcarlini at suse dot de
  2004-03-24 13:16 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2004-03-20 19:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-03-20 19:09 -------
.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

* [Bug libstdc++/13342] hash_map doesn't support std::string keys
  2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
                   ` (6 preceding siblings ...)
  2004-03-20 19:09 ` pcarlini at suse dot de
@ 2004-03-24 13:16 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2004-03-24 13:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-03-24 13:16 -------
*** Bug 14716 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mgd at technosis dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342


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

end of thread, other threads:[~2004-03-24 13:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-07 17:32 [Bug libstdc++/13342] New: hash_map doesn't support std::string keys kgirard at connect dot carleton dot ca
2003-12-07 17:37 ` [Bug libstdc++/13342] " pinskia at gcc dot gnu dot org
2003-12-07 17:59 ` kgirard at connect dot carleton dot ca
2003-12-07 18:49 ` gdr at integrable-solutions dot net
2003-12-09  3:08 ` bkoz at gcc dot gnu dot org
2004-01-21 20:45 ` pcarlini at suse dot de
2004-03-20 19:08 ` pcarlini at suse dot de
2004-03-20 19:09 ` pcarlini at suse dot de
2004-03-24 13:16 ` pcarlini at suse dot de

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).