I have a function that returns a std::vector<std::byte>
I am aware that std::byte
is not a character type nor an integral type, and that converting it to char is only possible through a typecast. So far so good.
So I would like (in cases where I know that the vector only contains character data) to transfer ownership of the underlying buffer from the std::vector<std::byte>
to a std::vector<char>
using std::move
, so as to avoid copying the entire underlying buffer.
When I try doing this, I get this error:
no suitable user-defined conversion from "std::vector<std::byte, std::allocatorstd::byte>" to "std::vector<char,std::allocator>" exists
Is this at all possible using C++? I think there are real use cases where one would want to do this