First of all, yes I know about FAQ Converting. But I don't need that kind of type-conversion (I hope!). We have:
#include <iostream>
#include <bitset>
#include <string>
#include <sstream>
struct My_Data{
  uint16_t data;
};
using namespace std;
int main()
{
  My_Data data{ 0x12 }; // data = 0x0012
  stringstream ss;
  ss << std::hex << static_cast<int>(data.data);
  string str_data{ ss.str() };
  cout << str_data;  // It will print 12, but I want 0012
  return 0;
}
My solution was std::bitset, I just wondering if there is another solution too.
because the main data type in the project is std::vector<uint8_t>, so is there any possible short way to get 0012 with std::vecotr<uint8_t>?
Thanks a lot.
 
     
    