Mike Copeland
2009-10-12 22:33:56 UTC
The following code fails to compile (VC6.0; errors C2440 & C2439),
and the offending code is the "find_if" line in main. (As with most MS
error diagnostics,) I can't make any sense out of the messages and don't
know what to do to correct the errors. Please advise. TIA
#pragma warning (disable:4786)
#include <map>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef struct ChipRec
{
int bibNum;
string entName;
} tData;
typedef multimap<string, ChipRec> CHIPINFO;
CHIPINFO mmci;
multimap<string, ChipRec>::iterator cIter;
tData tWork;
tData qWork;
typedef map<int, ChipRec> BCI;
BCI bci;
map<int, ChipRec>::iterator bIter;
class NameMatch
{
string m_name;
public:
NameMatch(string const &name) : m_name(name) {}
bool operator()(const map<int, ChipRec>::value_type const &v)
const
{
string nameWork;
nameWork = v.second.entName;
return nameWork == m_name;
}
};
int main()
{
string tStr = "The Phantom Spitter";
CHIPINFO::iterator it = find_if(mmci.begin(), mmci.end(),
NameMatch(tStr));
return 0;
}
and the offending code is the "find_if" line in main. (As with most MS
error diagnostics,) I can't make any sense out of the messages and don't
know what to do to correct the errors. Please advise. TIA
#pragma warning (disable:4786)
#include <map>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef struct ChipRec
{
int bibNum;
string entName;
} tData;
typedef multimap<string, ChipRec> CHIPINFO;
CHIPINFO mmci;
multimap<string, ChipRec>::iterator cIter;
tData tWork;
tData qWork;
typedef map<int, ChipRec> BCI;
BCI bci;
map<int, ChipRec>::iterator bIter;
class NameMatch
{
string m_name;
public:
NameMatch(string const &name) : m_name(name) {}
bool operator()(const map<int, ChipRec>::value_type const &v)
const
{
string nameWork;
nameWork = v.second.entName;
return nameWork == m_name;
}
};
int main()
{
string tStr = "The Phantom Spitter";
CHIPINFO::iterator it = find_if(mmci.begin(), mmci.end(),
NameMatch(tStr));
return 0;
}