I’ve been tasked with getting some old code working. It’s dated from 2006 and I believe it was written in visual studio. I get this error when compiling with g++ 4.5.2 using ming32 on a windows machine and I get the same error compiling with g++ 4.1.2 on a unix machine(not sure what flavor)
“_Dist_type was not declared in this scope”
#include <algorithm>
#include <vector>
template<class ReturnType, class RandomIterator, class _Ty> inline
ReturnType interpolate(RandomIterator _F, RandomIterator _L, const _Ty& _V, RandomIterator _F2)
{
return _Dist_type(_F);
}
class Interpolator
{
public:
double interp(const std::vector<double>& xValues, const std::vector<double>& yValues,
const double x0) const
{
//1-D interpolation
return interpolate<double>(xValues.begin(), xValues.end(), x0, yValues.begin());
}
};
I’ve tried googling for _dist_Type, but there doesn’t seem to be a lot of information out there. I did find one source, but I’m not sure how much it can help. http://en.allexperts.com/q/C-1040/STL-Iterator.htm
It’s my understanding that _Dist_type is part of a very old version of the STL library which neither build machine has. How could I solve this? I’m not even sure what the function does.
Any help is greatly appreciated.
_Dist_typeis an internal implementation detail used by Visual Studio’s standard library. Names starting with an underscore followed by an uppercase letter are reserved by the implementation and must never be called directly from user code.You’ll have to figure out what that function does and duplicate the functionality in a portable manner. If you’re lucky you might find that there is a function in the standard library that already implements this functionality and you can just replace the call.
EDIT:
Both Visual Studio 2005 & 2010 have
_Dist_typedefined asSo it is just returning a value of
0of typestd::iterator_traits<RandomIterator>::difference_type