0

Hello everyone! I am having a bit of an odd problem here.
So, on my Visual Studio project, I decided to use a precompiled header. This didn't seem to cause a noticable problem up until today.

I have a small segment of code that is supposed to remove one element of a vector based on it's contents:

using namespace std;
. . .
vector<int> v;
v.push_back(4); 
v.push_back(5);
v.push_back(6);
v.push_back(7);
v.erase(std::remove(v.begin(), v.end(), 6), v.end()); 

This USUALLY works. However, Visual Studio kept griping at me about how the synax is incorrect. So, I right-clicked on the remove function and found it's definition inside stdio.h:

_CRTIMP int __cdecl remove(_In_z_ const char * _Filename);

Hmm. Go figure. That seems to be a different remove function all together! This has stunted my progress, as I can't seem to find any help online for this.

Does anyone know how to fix this issue? Am I making a noob mistake?

I would greatly appreciate any comments.
-Kaleb

Edited by Hazardous_Byte

2
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by Hazardous_Byte
1

Did you include the header <algorithm>? Normally, this should be resolved by overloading. And you might also want to remove the using namespace std; statement. This remove function that you are getting is this one from cstdio. If you include the <algorithm> header, the overload resolution should be able to find the correct remove function.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.