0

I have a vector(details) containing class objects, i am trying to use find_if to look for a record in the vector. I searched through some solutions on it on stackoverflow and tried out the solutions.

e.g How to use std::find/std::find_if with a vector of custom class objects?

but on the line of find_if it gives me error

expected primary-expression before "[" token
expected primary-expression before "const"

    std::vector<user> details;
    std::string name;
    std::cout << "Please enter a name\n";
    std::cin >> name;

    std::find_if(details.begin(), details.end(),
                   [&name](user const& userInfo)
                   {return userInfo.getName()==name;});

I am using Dev-C++.

Community
  • 1
  • 1
user3493435
  • 81
  • 1
  • 3
  • 11
  • 1
    You need C++11 support for this. – juanchopanza Jan 08 '14 at 08:59
  • What compiler do you use with Dev-C++ ? – Raxvan Jan 08 '14 at 08:59
  • @Raxvan definitely not c++11. is there any way to write it in non c++11 way? – user3493435 Jan 08 '14 at 09:05
  • See @Schnommus' answer in the question you linked. – juanchopanza Jan 08 '14 at 09:07
  • @user3493435 it dependent on the compiler, if you have a newwer one you can add a switch in dev c to enable c++11 features. That's why i was asking for the compiler and it's version. – Raxvan Jan 08 '14 at 09:11
  • @Raxvan There are newer builds of Dev-C++, but from what I've seen on this site, everyone is using Dev-C++ packaged with outdated versions of mingw. –  Jan 08 '14 at 09:20
  • possible duplicate of [How to use std::find/std::find\_if with a vector of custom class objects?](http://stackoverflow.com/questions/6939129/how-to-use-stdfind-stdfind-if-with-a-vector-of-custom-class-objects) – juanchopanza Jan 08 '14 at 10:46

0 Answers0