std::map<std::string,int> Problem

T

tombert

Hi all,

can someone please tell me what's wrong with that code?
I am using gcc 4.7 from MinGW, under 4.6 it seemed to have compiled correctly.

The error is:
: error: no matching function for call to 'std::map<std::basic_string<char>, int>::insert(std::string&, int)'

Example:
class TDir {
typedef std::map<std::string,int> Subdirs;
public:
TDir(){}
~TDir(){}
void getDir(std::string name) {
Subdirs t;
t.insert(name,0);
}
};
 
Ö

Öö Tiib

Hi all,



can someone please tell me what's wrong with that code?

I am using gcc 4.7 from MinGW, under 4.6 it seemed to have compiled correctly.



The error is:

: error: no matching function for call to 'std::map<std::basic_string<char>, int>::insert(std::string&, int)'



Example:

class TDir {

typedef std::map<std::string,int> Subdirs;

public:

TDir(){}

~TDir(){}

void getDir(std::string name) {

Subdirs t;

t.insert(name,0);

Should be:
 
L

Luca Risolia

Hi all,

can someone please tell me what's wrong with that code?
I am using gcc 4.7 from MinGW, under 4.6 it seemed to have compiled correctly.

The error is:
: error: no matching function for call to 'std::map<std::basic_string<char>, int>::insert(std::string&, int)'
class TDir {
typedef std::map<std::string,int> Subdirs;
public:
TDir(){}
~TDir(){}
void getDir(std::string name) {
Subdirs t;
t.insert(name,0);
^^^^^^

It's strange gcc4.6 compiled that code.

try with std::make_pair from <utility>:
t.insert(std::make_pair(name,0));
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,131
Members
46,689
Latest member
liammiller

Latest Threads

Top