Thread: Map Problem

  1. #1
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718

    Map Problem

    Code:
    typedef INIKey pair< string, string >;
    //...
    map< INIKey, string > mData;
    //...
    mData.insert( INIKey( sectionName, keyName ), value );
    And when I compile it, I get the following error: 'No constructor could take the source type, or constructor overload resolution was ambiguous' on the insert line.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Why not use the make_pair() function?

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    backwards is your typedef
    typedef pair< string, string > INIKey;
    insert takes a pair of type map::value_type where value_type is a pair<key_type, data_type> in your (rather odd) case its a pair< pair<string,string>, string>. make_pair() will clean this up.

    I get the impression that what you really want is
    map<string, map<string,string> >
    that is a map for every section from key to value's.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Sorry, I have my typedef correct in the program, just not here. I forgot that insert( ) takes a pair. Thanks.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a map engine.
    By suzakugaiden in forum Game Programming
    Replies: 11
    Last Post: 06-21-2005, 05:06 AM
  2. problem with a map iterator
    By anykey in forum C++ Programming
    Replies: 17
    Last Post: 04-29-2005, 11:49 PM
  3. STL MAP Question
    By deadpoet in forum C++ Programming
    Replies: 11
    Last Post: 02-24-2004, 06:37 AM
  4. Searching STL Map Inside STL Map Object :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2002, 09:11 AM
  5. my map is showing up 90 degrees turned!
    By frenchfry164 in forum C++ Programming
    Replies: 8
    Last Post: 03-28-2002, 02:32 PM