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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top