错误:“ numeric_limits”不是类模板

时间:2018-12-05 14:40:58

标签: c++ templates

我想编译代码,但收到错误消息。第一个:  ../base/cmvs/../stann/sep_float.hpp:50:7:错误:“ numeric_limits”不是类模板  类numeric_limits>

这是文件:

using namespace std;

template<typename T>
class sep_float;

namespace std
{
template<>
class numeric_limits<sep_float<float> >
{
public:
    static const bool is_specialized = true;
    static float max() throw() {return numeric_limits<float>::max();}
    static float min() throw() {return  -numeric_limits<float>::max();}
 };

这不是我自己的代码,在c ++中我也不是那么高级。我知道该如何解决?

1 个答案:

答案 0 :(得分:0)

问题在于此标头应该是自给自足的,并包含声明此类型特征的标头:

#include <limits>

请注意,在标头中添加using namespace std不仅仅是一种不好的做法。去掉它。