473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

insert in std::map does not insert the object

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::stringvcTemp;
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 '07 #1
1 1504
My question is no more valid: I was looking at the wrong part of code.
Sorry

On Nov 4, 11:48 pm, simon.el...@free.fr 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::stringvcTemp;
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 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Christopher | last post by:
I am having problems iterating through the sequence of objects stored in my std::map I want to call a function from the "value" object in the map. Here is my snippet: typedef std::map<SOCKET,...
1
by: Antti Granqvist | last post by:
Hello! I have following object relations: Competition 1--* Category 1--* Course 1 | | * Course
5
by: cppaddict | last post by:
Hi, I'm confused about what the comparison operator in a map template is: In particular, I want to know why something like the following doesn't work: bool pointCompare(POINT p1, POINT p2)...
14
by: Flzw | last post by:
Well I have a map like this : std::map <string, CObject> ObjectList; I have a function like this : CObject* NewObject( char* Name, CArg* Arg) { std::string key = Name; ObjectList =...
1
by: Saeed Amrollahi | last post by:
Dear All C++ Programmers Hello I am Saeed Amrollahi. I am a software engineer in Tehran Sewerage Company. I try to use std::map and map::find member function. I use Visual Studio .NET. my...
13
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
21
by: aaragon | last post by:
Hello everyone, I would like to know if there is a way to use the std::map to store different types for one of its two types. That is, I'm trying to use it as: typedef...
5
by: Diwa | last post by:
Does the "value" type (value as in key-value pair )of "std::map" require a default ctor even if it is not used ? If I comment out Line 1 in the code attached later, i.e remove the default ctor...
7
by: guido | last post by:
Hi, I'm looking for a container class that can map whole ranges of keys to objects - something like std::map, but not only for individual values for the key, but for whole ranges. Example: I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.