Somehow, whatever I try (which is rather random at this point), I never get it right.
Consider the following code:
class A
{
public:
void disconnect(Slot *c, void (Slot::*f)(Component *)) // pointer to class, pointer to memberfunction with parameter (Component *)
{
for (int i = 0; i < (int) pointers.size(); ++i)
{
if (((pointers.instance)->(pointers.function))(Component *) == (c->(f))(Component *))
{
// function pointers point to the same function
}
}
}
private:
struct Pointer
{
Slot *instance;
void (Slot::*function)(Component *);
};
std::vector<Pointer> pointers;
};
The problem is this part:
((pointers.instance)->(pointers.function))(Component *) == (c->(f))(Component *)
Where I try to compare if the pointer that is given through the function parameters, is the same as the pointer I test in the vector. It keeps giving me errors like these:
error: expected unqualified-id before '(' token
error: expected primary-expression before '*' token
error: expected primary-expression before ')' token
error: expected unqualified-id before '(' token
error: expected primary-expression before '*' token
error: expected primary-expression before ')' token
And I've come to a point where I'm absolutly clueless...even worse, I had it working before, didn't make a backup or used SVN yet '-.-
If there is a more elegant way of checking if a certain value is in a vector, please do tell me ;)
[Edited by - Decrius on July 30, 2008 5:18:30 PM]