This is a bit loaded question since after reading about std::move(), I am more confused. std::move() will cast a variable to an rvalue.
My question.
- Does it make any sense to use std::move for primitive data type like std::string.
Now, if yes. Here is my code
std::string val;
Mypersist store();
store.restore(val);
setAttribute(val);
//after this I don't care about val.
int Mypersist::store(std::string &value)
{
}
void setAttribute(const std::string &value)
{
}
I am already using reference rather than value copy so I am a bit confused if std::move makes sense here or not.
I have this in my mind.
Is using std::move(val) for setAttribute will help in performance? If so why?
std::string val;
Mypersist store();
store.restore(val);
setAttribute(std::move(val));
//after this I don't care about val.
Aucun commentaire:
Enregistrer un commentaire