#include #include using std::string; template void PrintHex(T& obj) { auto size = sizeof(T); std::cout << type_name().View() << "<" << size <<"> " << " = 0x"; char* ptr = (char*)& obj; for (int i = 0; i < size; i++) { std::cout << std::hex << std::setw(2) << std::setfill('0') <<(int)*(ptr + i); } std::cout << "FF" << std::endl; } void TestString1() { string hello = "abcdef"; int size = sizeof(string); PrintHex(hello); hello = "abcdefabcdefabcdefabcdef"; PrintHex(hello); //hello.~basic_string(); PrintHex(size); }