How do I convert a std::string
to a std::vector<std::byte>
in C++17?
Edited: I am filling an asynchronous buffer due to retrieving data as much as possible. So, I am using std::vector<std::byte>
on my buffer and I want to convert string to fill it.
std::string gpsValue;
gpsValue = "time[.........";
std::vector<std::byte> gpsValueArray(gpsValue.size() + 1);
std::copy(gpsValue.begin(), gpsValue.end(), gpsValueArray.begin());
but I am getting this error:
error: cannot convert ‘char’ to ‘std::byte’ in assignment
*__result = *__first;
~~~~~~~~~~^~~~~~~~~~