_Dist_type 未在此范围内声明

发布于 2024-12-10 17:42:45 字数 1047 浏览 0 评论 0原文

我的任务是让一些旧代码正常工作。它的日期是 2006 年,我相信它是在 Visual Studio 中编写的。在 Windows 机器上使用 ming32 编译 g++ 4.5.2 时出现此错误,在 unix 机器上使用 g++ 4.1.2 编译时出现相同的错误(不确定是什么风格)

“_Dist_type 未在此范围内声明”

#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'我尝试在谷歌上搜索 _dist_Type,但似乎没有很多信息。我确实找到了一个来源,但我不确定它能有多大帮助。 http://en.allexperts.com/q/C-1040/STL -Iterator.htm

据我了解,_Dist_type 是 STL 库的一个非常旧版本的一部分,这两个构建机都没有。我该如何解决这个问题?我什至不确定该功能的作用。

非常感谢任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染火枫林 2024-12-17 17:42:45

_Dist_type 是 Visual Studio 标准库使用的内部实现细节。以下划线开头且后跟大写字母的名称由实现保留,绝不能直接从用户代码中调用。

您必须弄清楚该函数的作用,并以可移植的方式复制该功能。如果幸运的话,您可能会发现标准库中有一个函数已经实现了此功能,您只需替换该调用即可。

编辑:
Visual Studio 2005 和 Visual Studio 2005 2010 将 _Dist_type 定义为

template<class _Iter> inline
typename iterator_traits<_Iter>::difference_type
*_Dist_type(_Iter)
{   // return distance type from arbitrary argument
  return (0);
}

所以它只是返回 std::iterator_traits::difference_type 类型的 0

_Dist_type is 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_type defined as

template<class _Iter> inline
typename iterator_traits<_Iter>::difference_type
*_Dist_type(_Iter)
{   // return distance type from arbitrary argument
  return (0);
}

So it is just returning a value of 0 of type std::iterator_traits<RandomIterator>::difference_type

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文