[Developers] Is this what we want?
John Sibert
sibert at hawaii.edu
Wed Dec 12 16:53:40 PST 2012
While perusing some code this morning I came across the following in
tools99/ad_cif.cpp
cifstream& cifstream::operator>>(const dvector& z)
{
if (allocated(z))
for (int i= z.indexmin(); i <= z.indexmax(); i++)
{
*this >> z[i];
}
return *this;
}
If I'm reading this correctly, if memory for the dvector z is allocated
the for loop is executed changing the elements of z (in spite of the
const keyword). On the other hand if z is not allocated, the stream
pointer is simply returned to whatever called the operator and the
elements of z are not changed.
This is the correct action if z in not allocated, but should there be a
warning or an error exit?
Cheers,
John
--
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa
Visit the ADMB project http://admb-project.org/
More information about the Developers
mailing list