我在尝试使用 std::lower_bound 函数时收到著名的 C4100 警告。
这是我的代码:
typedef std::vector<SDTSPosition> TPTSFileOffsetVector;
TPTSFileOffsetVector::iterator lowest_nearest = std::lower_bound(m_position_table.begin(),
m_position_table.end(), SDTSPosition(dts_position, 0), SDTSPosition());
比较器在结构内部:
// positioning
struct SDTSPosition
{
SDTSPosition() {}
SDTSPosition(int d, int p)
{
dts = d;
pos = p;
}
int dts;
int pos;
bool operator()(const SDTSPosition & left, const SDTSPosition & right) const
{
return left.dts < right.dts;
}
};
编译警告将我指向 STL 中的这段代码:
template<class _FwdIt,
class _Pr> inline
void __CLRCALL_OR_CDECL _Debug_order_single2(_FwdIt _First, _FwdIt _Last, _Pr _Pred, bool _IsFirstIteration,
const wchar_t *_File, unsigned int _Line, forward_iterator_tag)
{ // test if _First and ++_First ordered by predicate, forward iterators
if (_First != _Last)
{
_FwdIt _Next = _First;
if (++_Next != _Last)
if (_DEBUG_LT_PRED(_Pred, *_Next, *_First))
_DEBUG_ERROR2("sequence not ordered", _File, _Line);
}
}
确实没有对所述 bool 变量的引用。
我做错了什么吗? (顺便说一下,这是 VS2005)
最佳答案
起初我会说你没有做错任何事。
在我看来,他们只是忘记了使用该参数,或者他们无法更新签名而忘记关闭此功能的警告。
我不会担心。
关于c++ - '_IsFirstIteration':std::lower_bound 中未引用的形参,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17722152/