The error message: "binary '==': no operator found which takes a left-hand operand of type 'const _Ty' (or there is no acceptable conversion)"
The error seems to be because I'm giving std::remove a const value for the first argument, but I don't see exactly how v.begin() being unmodifiable would cause problems, nor why this error only occurs if the type of the vector is templated, as opposed to a known type vector.
The template function:
// Erases a every element of a certain value from a vector
template <typename T>
std::vector<T> eraseElement(std::vector<T> v, T elem)
{
typename std::vector<T>::iterator newEnd = std::remove(v.begin(), v.end(), elem);
v.erase(newEnd, v.end());
return v;
}
An example of the way I'm calling the template function:
struct exampleStruct
{
int x;
}
std::vector<exampleStruct> v;
exampleStruct elem;
elem.x = 2451;
v.push_back(elem);
v = eraseElement(v, elem);