0

I'm trying to store a QString and a bool in a vector as a pair. I keep getting the error

no matching function for call to 'make_pair(bool, QString&)' messages.push_back(make_pair(true, message));

when I run following function:

void Class::setMessage(){
    QTime time = QTime::currentTime();
    QString message = time.toString() + "-" + "My message";
    vector<pair<bool,QString>> messages;
    messages.push_back(make_pair<bool,QString>(true, message));
}

Whats missing in my code?

isADon
  • 3,433
  • 11
  • 35
  • 49

1 Answers1

2

This should work. You don't need to specify the template parameters. They're deduced. I'm assuming you're using std. Perhaps qualify make_pair with std. Remember to include utility.

Also, make sure that the names used are declared the expected scope.

Werner Erasmus
  • 3,988
  • 17
  • 31
  • you are right about specifying the template again. That was the problem. Thanks for the help! – isADon Aug 07 '14 at 18:45