B
Bob
#include <vector>
#include <cstring>
namespace
{
void bad()
{
std::vector<bool> v(0);
v.push_back(true);
v.push_back(false);
v.push_back(true);
bool b = v[0];
bool* ba = new bool[v.size()];
bool& c = v[0];
std::memcpy(ba, &c, sizeof(bool) * v.size());
delete [] ba;
}
}
int main()
{
foo();
return 0;
}
#include <cstring>
namespace
{
void bad()
{
std::vector<bool> v(0);
v.push_back(true);
v.push_back(false);
v.push_back(true);
bool b = v[0];
bool* ba = new bool[v.size()];
bool& c = v[0];
std::memcpy(ba, &c, sizeof(bool) * v.size());
delete [] ba;
}
}
int main()
{
foo();
return 0;
}