我需要保存一些数据,唯一可行的选择是std::string; 所以我得到一个作为void*. 现在我需要以一种可以将其转换为 astd::string并能够从该确切字符串中读取void*a的方式来保存它。bool[]可悲的是,我迷失在转换中。
f(const void* data, int length){
bool** boolPointer = (bool**)(data);
bool boolArray[length];
for (int i=0; i<=length; i++){
boolArray[i] = p[sizeof(bool)*i];
}
std::string s = (std::string&)boolArray;
}
我很确定最后一行不是可行的转换,但那是我的尝试。