I am trying to run the count occurrences of elements in a vector code listed in the answer here.
But I'm running into compile errors in this function:
auto h = [](const std::string* s) {
return std::hash<std::string>()(*s);
};
stating Expected expression
around the [ ]
. I know this has to do with the compiler.
I'm using Xcode 5.0.2
, so I have the option to change the compiler (I think).
Then I'm getting another compile error on the line:
std::unordered_map<const std::string*, size_t, decltype(h), decltype(eq)> m(v.size(), h, eq);
stating C++ requires a specifier for all declarations
around the m(v.size(), h, eq)
portion.
What compiler should I make sure Xcode
is compiling with in order to get this code to work?
Update:
Is there a particular name for this auto = [ ](...)
notation that I could google?
Do you know what standard is taking into account?
Try to force to C++11, to cover these lambda
structures and unordered_map
.