insert in std::map does not insert the object

Discussion in 'C++' started by simon.elbaz@free.fr, Nov 4, 2007.

  1. Guest

    Hi,
    i use the following map:

    std::map<Key, std::vector< std::string >, KeyCmp > mSQLElem;

    The following code does not insert the newly created pair:
    std::vector<std::string> vcTemp;
    vcTemp.push_back("test string");
    mSQLBody.insert(std::make_pair(Key(stKey, mSQLBody.size(),
    b_is_key_unique), std::vector< std::string >(vcTemp)));

    Thanks for your help!
    Simon

    ////////////////////////////////////////////

    The Key class is:
    class Key {
    public:
    std::string stKeyName;
    bool bFilled;
    bool b_is_unique; // should this node be unique in the pattern
    int iPosition;

    Key(std::string a_stKeyName, int a_iPosition=-1, bool
    a_b_is_unique=false) : stKeyName(a_stKeyName), iPosition(a_iPosition),
    bFilled(false), b_is_unique(a_b_is_unique)
    {}

    Key(const Key &a_key);
    Key &operator=(const Key &a_key);
    void clear();
    };

    and KeyCmp class:
    class KeyCmp {
    public:
    bool operator()(Key const &, Key const &) const;
    };
     
    , Nov 4, 2007
    #1
    1. Advertising

  2. Guest

    My question is no more valid: I was looking at the wrong part of code.
    Sorry

    On Nov 4, 11:48 pm, wrote:
    > Hi,
    > i use the following map:
    >
    > std::map<Key, std::vector< std::string >, KeyCmp > mSQLElem;
    >
    > The following code does not insert the newly created pair:
    > std::vector<std::string> vcTemp;
    > vcTemp.push_back("test string");
    > mSQLBody.insert(std::make_pair(Key(stKey, mSQLBody.size(),
    > b_is_key_unique), std::vector< std::string >(vcTemp)));
    >
    > Thanks for your help!
    > Simon
    >
    > ////////////////////////////////////////////
    >
    > The Key class is:
    > class Key {
    > public:
    > std::string stKeyName;
    > bool bFilled;
    > bool b_is_unique; // should this node be unique in the pattern
    > int iPosition;
    >
    > Key(std::string a_stKeyName, int a_iPosition=-1, bool
    > a_b_is_unique=false) : stKeyName(a_stKeyName), iPosition(a_iPosition),
    > bFilled(false), b_is_unique(a_b_is_unique)
    > {}
    >
    > Key(const Key &a_key);
    > Key &operator=(const Key &a_key);
    > void clear();
    >
    > };
    >
    > and KeyCmp class:
    > class KeyCmp {
    > public:
    > bool operator()(Key const &, Key const &) const;
    >
    > };
     
    , Nov 4, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Jansson
    Replies:
    5
    Views:
    6,439
    Ivan Vecerina
    Mar 17, 2005
  2. Replies:
    1
    Views:
    456
    red floyd
    Dec 21, 2008
  3. Thomas J. Gritzan
    Replies:
    6
    Views:
    1,051
    James Kanze
    Dec 22, 2008
  4. James Kanze
    Replies:
    0
    Views:
    2,068
    James Kanze
    Dec 21, 2008
  5. Neelesh
    Replies:
    5
    Views:
    1,063
    James Kanze
    May 24, 2009
Loading...

Share This Page