isADon
isADon

Reputation: 3673

QT: Error trying to store QString in std::pair

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?

Upvotes: 0

Views: 505

Answers (1)

Werner Erasmus
Werner Erasmus

Reputation: 4076

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.

Upvotes: 2

Related Questions