I assume this is not possible because I received the following error:
error C3533: 'auto': a parameter cannot have a type that contains 'auto'
Here is a code snippet for reproducing the error:
int myInts[] = {1,2,3,3,3,4}; std::vector<int> myVec(myInts, myInts + sizeof(myInts)/sizeof(int)); myVec.erase( std::remove_if(myVec.begin(), myVec.end(), [](auto i){return i==3;}),
Now, if you have to write this, everything will be fine, and it erases the elements with a value of 3:
int myInts[] = {1,2,3,3,3,4}; std::vector<int> myVec(myInts, myInts + sizeof(myInts)/sizeof(int)); myVec.erase( std::remove_if(myVec.begin(), myVec.end(), [](int i){return i==3;}), myVec.end());
So, can you just not use auto as a function parameter, as the error shows?
Is it because the type auto is determined by the value r, which the compiler cannot infer, despite the fact that it is a predicate of an algorithm executed on the well-known vector int ?
Does anyone know the reason?