As the question, I want to implement this kind of zero-copy,in the process of sending and receiving data in the network, C-style strings will often be used, but the upper layer want to use std::string,What should I do?
Asked
Active
Viewed 35 times
0
-
3`std::string` manages its own memory. There is no way for it to take ownership of your c-style string. Can you use a `string_view` instead? – NathanOliver Jul 21 '22 at 14:22
-
... at the risk of, erm, tying yourself in knots with dangling pointers / references. – Paul Sanders Jul 21 '22 at 14:30