Is there a way to move the content from a std::string into a std::vector? I think with now having rvalue-references in the language this operation would be very useful sometimes.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is theoretically possible to move from one object type to another. However, those object types have to be designed to allow this.
vectorandstringare not.A good clue that an object allows it would be if
std::vectorhas a constructor that takes astd::string&&. It has no such constructor. Also,vectorwould have to be a friend ofstringto get at its internals.