M
Mike Copeland
I am trying to develop code that will "find" if a value exists in an
STL list structure. Perhaps I'm being too clever in my attempt to use
code snippets I've found (and maybe I should be doing this search in a
more brute-force manner with an iterator loop), but what I have is the
code below. It doesn't compile (many errors), so I know I'm
misunderstanding something fundamental.
I probably need to use find_if with this (mess), but I haven't gotten
far enough to see what will actually work. Note that I'm using a list
because there's no unique key and "body" values may be duplicated.
Please advise. TIA
class DBE_DATA
{
public
struct DBEBUILD
{
int bibNumber;
char source;
string body; // this is the data I want to match
} dbeWork;
list<DBEBUILD> zeroBibList;
list<DBEBUILD>::iterator zblIter;
};
struct sameName: public binary_function<DBE_DATA, string, bool>
{
bool operator()(const DBE_DATA *oldName, string newName) const
{
return oldName == newName;
}
};
STL list structure. Perhaps I'm being too clever in my attempt to use
code snippets I've found (and maybe I should be doing this search in a
more brute-force manner with an iterator loop), but what I have is the
code below. It doesn't compile (many errors), so I know I'm
misunderstanding something fundamental.
I probably need to use find_if with this (mess), but I haven't gotten
far enough to see what will actually work. Note that I'm using a list
because there's no unique key and "body" values may be duplicated.
Please advise. TIA
class DBE_DATA
{
public
struct DBEBUILD
{
int bibNumber;
char source;
string body; // this is the data I want to match
} dbeWork;
list<DBEBUILD> zeroBibList;
list<DBEBUILD>::iterator zblIter;
};
struct sameName: public binary_function<DBE_DATA, string, bool>
{
bool operator()(const DBE_DATA *oldName, string newName) const
{
return oldName == newName;
}
};