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.
It is theoretically possible to move from one object type to another. However, those object types have to be designed to allow this. vector
and string
are not.
A good clue that an object allows it would be if std::vector
has a constructor that takes a std::string&&
. It has no such constructor. Also, vector
would have to be a friend of string
to get at its internals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With