M
marco_segurini
Hi,
if I compile the following code I get the error:
RemoveIf.cpp(19) : error C2914: 'remove_if' : cannot deduce template
argument as function argument is ambiguous
#include <algorithm>
#include <vector>
template<typename T>
class vector_t
: public std::vector<T>
{
bool TestRemove(long Pos) const //(1)
{
return false;
}
static bool TestRemove(const T &) //(2)
{
return false;
}
public:
void RemoveIf()
{
erase(std::remove_if(begin(), end(), &vector_t<T>::TestRemove),
end()); //this is line 19
}
};
typedef struct point
{
long x;
long y;
long f;
} point;
int main()
{
vector_t<point> vp;
vp.RemoveIf();
return 0;
}
How may I force the remove_if to use the TestRemove (2) function as
predicate?
TIA.
Marco.
if I compile the following code I get the error:
RemoveIf.cpp(19) : error C2914: 'remove_if' : cannot deduce template
argument as function argument is ambiguous
#include <algorithm>
#include <vector>
template<typename T>
class vector_t
: public std::vector<T>
{
bool TestRemove(long Pos) const //(1)
{
return false;
}
static bool TestRemove(const T &) //(2)
{
return false;
}
public:
void RemoveIf()
{
erase(std::remove_if(begin(), end(), &vector_t<T>::TestRemove),
end()); //this is line 19
}
};
typedef struct point
{
long x;
long y;
long f;
} point;
int main()
{
vector_t<point> vp;
vp.RemoveIf();
return 0;
}
How may I force the remove_if to use the TestRemove (2) function as
predicate?
TIA.
Marco.