C++11/14 convert std::uint32 to std::vector

I would like to convert std::uint32 to std::vector<std::uint8> in a better way than this:

std::uint32_t base_rva = 0xccddee00;
std::vector<std::uint8_t> vraw_data;

//copying base_rva to raw_data
vraw_data.resize(sizeof(base_rva));
std::memcpy(vraw_data.data(), &base_rva, sizeof(base_rva)); 

I was looking for something like:

std::vector<std::uint8_t> vraw_data((std::uint8_t*)&base_rva, sizeof(base_rva));

Any suggestions?

Answer

I was looking for something like:

std::vector<std::uint8_t> raw_data((std::uint8_t*)&base_rva, sizeof(base_rva));

There’s no such constructor available for std::vector, but supposed you want to store the copy of a std::uint32_t internal representation in a std::vector<std::uint8_t> you can simply do

 std::uint32_t data = 42;
 std::vector<std::uint8_t> raw_data( (std::uint8_t*)&data
                                   , (std::uint8_t*)&(data) + sizeof(std::uint32_t));

according (4) from std::vector constructors.