2012-03-26 16 views
10

Właśnie napotkałem dziwny błąd, który mówi, że find nie jest członkiem standardu.error C2039: 'find': nie jest członkiem 'std'

error C2039: 'find': nie jest członkiem 'std'

error C3861: 'find': identyfikator nie znaleziono

Zasadniczo, chcę znaleźć, czy ciąg znaków można znaleźć w wektorze

Każdy pomysł, dlaczego tak się dzieje? Asystent kodu mówi mi, że istnieje metoda w standardzie.

tak to jest w zasadzie to, co zrobiłem:

#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; 
    } 
} 
+0

Czy próbowałeś googlować? Ponadto ten przykład kodu nie jest kompilowany, ponieważ nie miałem reszty kodu. W przyszłości spróbuj opublikować próbki kodu http://sscce.org - znacznie łatwiej jest podać poprawną odpowiedź. –

Odpowiedz

29

std::find jest zdefiniowany w nagłówku <algorithm>. Dodaj do początku:

#include <algorithm> 
+0

to działa. Czy możesz podać mi powód, dlaczego tak się dzieje? – Rudy

+10

@Rudy Ponieważ standard C++ mówi, std :: find znajduje się w nagłówku . – juanchopanza

Powiązane problemy