I need to save some data and the only viable option is a std::string; so I get a bool array passed as a void*. Now I need to save it in a way that I can convert it into a std::string and be able read a void* to a bool[] from that exact string. Sadly I got lost in conversion.
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;
}
I’m pretty sure the last line is no viable conversion, but that was my attempt.
Does this work for you?
If you are on C++11, you can use the following code snippet