What is the 'proper' way in C++11 and beyond to initialise a std::array from a pointer into a buffer?
I currently have
using guid_t = std::array<uint8_t, 16>;
inline guid_t make_guid(const uint8_t * bytes)
{
guid_t res;
for (int i = 0; i < res.size(); i++)
{
res[i] = bytes[i];
}
return res;
}
in my code but this just appears sloppy and inefficient - it seems like this should be a one liner using something in the standard libraries however I can't find it anywhere via searching.
Aucun commentaire:
Enregistrer un commentaire