CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2001
    Posts
    143

    hash_set and std::string

    Friends, i am doing something like:

    using namespace std;

    hash_set<string> myhashstring;

    myhashstring.insert("USA");


    As such program is giving me error that:

    (38): error C2440: 'type cast' : cannot convert from 'const std::string' to 'size_t'


    But if i use "set" instead of "hash_set" the program works normally. Any one guess whats the problem ???

  2. #2
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    hash_set is not part of ISO standard C++. It's entirely possible that there's a bug in whatever standard library implementation you're using. We'll need a few more details to pin it down, though.
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


  3. #3
    Join Date
    Sep 2001
    Posts
    143
    I am using the hash_set implementation that comes with VC++ 7.0 compiler.

  4. #4
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    Sorry, can't help, since I've not used VC++ 7.0
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured