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

22,410

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

#include <algorithm>
Share:
22,410
Rudy
Author by

Rudy

Updated on March 26, 2020

Comments

  • Rudy
    Rudy about 4 years

    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;
       }
    }
    
  • juanchopanza
    juanchopanza about 12 years
    @Rudy Because the C++ standard says std::find is in the <algorithm> header.