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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.