Nothing bad will happen, as the vector creates a copy of the pair (and each of the two lines in it).
To support this, here is the corresponding quote from the Standard (C ++ 11, ยง23.2.3, in the large table on page 738 of the official publication):
a.push_back(t) [...] Adds a copy of t // Requires: t must be CopyInsertable in X
Here X denotes a vector type and t for an lvalue or constant rvalue of type t , which is the type of member elements. So this is relevant to your case. (If the pair were created on the fly, that is, inside the call to the push_back(...) function, you would have a temporary rvalue value, which means that a different table of tables will be used, and you will get a copy instead, but there would be no problem.)
Vector stores copies of its elements. (The only danger is when you have a vector whose element types are defined as a pointer type, or some structure or class that has pointer elements. Then the vector, of course, only makes copies of the pointers, not deep copies of the contents, or in the case of a structure or class type, it creates copies defined by the copy constructor of this data type. But for std::pair of std::string everything will work as expected.)
source share