N
ngaloppo
Hi,
I sometimes convert std::vector::iterators to pointers by the (afaik)
legal construct &v[0], e.g. in the construct below. In debug build, the
program terminates, because of what seems to be part of the new checked
iterators in VC8. OTOH, I thought that the code is perfectly legal. Is
it safe to temporarily disable _HAS_ITERATOR_DEBUGGING here? I feel
bad about just shutting up the compiler.
Thanks!
bool QuadsFileIO::Read(const std::string& fn, std::vector<float>&
verts, std::vector<float>& texcoords) {
ifstream ifile(fn.c_str(), ios::binary | ios::in);
if (!ifile.is_open())
{
std::cout << "Warning: Couldn't open file for reading " << fn <<
std::endl;
return false;
}
typedef std::vector<float>::size_type size_type;
size_type size;
ifile.read((char*)&size, sizeof(size_type));
verts.resize(size);
texcoords.resize(size);
ifile.read((char*)&verts[0], sizeof(float) * size);
ifile.read((char*)&texcoords[0], sizeof(float) * size);
ifile.close();
return true;
}
I sometimes convert std::vector::iterators to pointers by the (afaik)
legal construct &v[0], e.g. in the construct below. In debug build, the
program terminates, because of what seems to be part of the new checked
iterators in VC8. OTOH, I thought that the code is perfectly legal. Is
it safe to temporarily disable _HAS_ITERATOR_DEBUGGING here? I feel
bad about just shutting up the compiler.
Thanks!
bool QuadsFileIO::Read(const std::string& fn, std::vector<float>&
verts, std::vector<float>& texcoords) {
ifstream ifile(fn.c_str(), ios::binary | ios::in);
if (!ifile.is_open())
{
std::cout << "Warning: Couldn't open file for reading " << fn <<
std::endl;
return false;
}
typedef std::vector<float>::size_type size_type;
size_type size;
ifile.read((char*)&size, sizeof(size_type));
verts.resize(size);
texcoords.resize(size);
ifile.read((char*)&verts[0], sizeof(float) * size);
ifile.read((char*)&texcoords[0], sizeof(float) * size);
ifile.close();
return true;
}