I'm implementing a HTTP server and the API I follow define the raw response data as a std::vector<std::byte>>.
I store http responses headers as std::string in my code and at some point I have to write them to to raw response data before sending it back.
The thing is, I cannot find a clean way to write/append data from a std::string to my std::vector<std::byte>> (by clean way I mean not looping on the string and appending each char).
What is the best way to do that ?
Side question: What is the best way to read a string from a std::vector<std::byte>> ?
std::stringhave a constructor taking an iterator pair)?chardo not fit instd::bytestd::transform(headers.begin(), headers.end(), std::back_inserter(response), [](char c) { return std::byte(c); } );where lambda isencode().