|
|
|
|
|
by drivebyhooting
8 days ago
|
|
It’s not semantically safe to pass arbitrary vectors into a generic buffer copying function. The T in a vector<T> could have internal pointers or worse things. Either the objects are simple and trivially copiable, or you need a proper serialization library. Sure you can use span to generalize slides and iteration, but I don’t think that’s the point of the article. |
|
In contrast, with span, you can instantiate only to span<uint_8> (or something similar) and you'd still be able to accept other buffer types (such as vector<uint_8>, array<uint_8>, etc.). Alternatively, you can make T bounded to be trivially copyable. You can't do that with void*.