std::equal 使用 -std=gnu++11 开关编译时出错

std::equal error while compiling with -std=gnu++11 switch

当我在没有 -std=gnu++11 开关的情况下编译时,这个循环工作正常。如果我使用 -std=gnu++11 编译,我会收到以下错误:

no match for call to '(__gnu_cxx::__normal_iterator<const float*, std::vector<float> >) (const float&, const float&)' if (!bool(__binary_pred(*__first1, *__first2))) 

我的代码:

for (auto it_A = std::begin(vector_A); it_A != std::end(vector_A); it_A += 4)
{
    bool found_in_B = false;
    for (auto it_B = std::begin(vector_B); !found_in_B && it_B != std::end(vector_B); it_B += 4)
    {
        found_in_B = std::equal(it_A, it_A + blockSize, it_B, it_B + blockSize);
    }
}

直到 C++14,std::equal 采用三个迭代器:两个描述第一个范围,一个描述第二个范围的开始。它没有理由采用第四个迭代器,因为两个范围必须具有相同的长度(同样,直到 C++14)。

四迭代器版本是在 C++14 中添加的,不适用于您选择的语言变体(该标志影响标准库,而不仅仅是语言)。

由于范围长度在您的代码中始终匹配,因此您可以删除第四个参数。