Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

std

vector

I just encountered a weird error which saying that find is not a member of std.

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

error C3861: 'find': identifier not found

Basically, I want to find whether a string can be found in the vector

Any idea why does this happen? the code assist tells me that there is find method in std.

so this is basically what I did :

#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;
   }
}
like image 385
Rudy Avatar asked Mar 26 '12 07:03

Rudy


1 Answers

std::find is defined in the <algorithm> header. Add to the beginning:

#include <algorithm>
like image 169
Rafał Rawicki Avatar answered Nov 17 '22 11:11

Rafał Rawicki