【问题标题】:error C2039: 'find' : is not a member of 'std'错误 C2039:“查找”:不是“标准”的成员
【发布时间】:2012-03-26 07:10:38
【问题描述】:

我刚刚遇到一个奇怪的错误,说 find 不是 std 的成员。

error C2039: 'find' : is not a member of 'std'

错误 C3861:“查找”:未找到标识符

基本上,我想在向量中查找是否可以找到字符串

知道为什么会这样吗?代码辅助告诉我std中有find方法。

所以这基本上就是我所做的:

#include "OperatorUtil.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <sstream>


using namespace saeConfig;


namespace operatorUtil
{
   bool isIn(const Filter filter, const SearchKey key)
   {
    
    bool result = false;

    
    string dimensionStr = key.dimensions.getValue(filter.getFilterKey());
    if(filter.getFilterValues().size()>0)
    {
        vector<string> vstr= filter.getFilterValues();
        std::vector<string>::iterator it;        // Iterator
        it = std::find(vstr.begin(), vstr.end(), dimensionStr);  //ERROR LINE  
        // Check do we have the object in the queue
        if(it == vstr.end())    
        {           
            result =true;
        }
    }

    return result;
   }
}

【问题讨论】:

  • 你试过谷歌搜索吗?此外,此代码示例不可编译,因为我没有您的其余代码。为将来尝试发布sscce.org 代码示例 - 给出正确答案要容易得多。

标签: c++ vector std


【解决方案1】:

std::find 在&lt;algorithm&gt; 标头中定义。添加到开头:

#include <algorithm>

【讨论】:

  • @Rudy 因为 C++ 标准说 std::find 在 标头中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-11
  • 2015-06-22
  • 1970-01-01
相关资源
最近更新 更多