Re: how do I find an item in std::list?
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Wed, 19 Sep 2007 15:35:55 -0400
Jack <jl@xxxxxxxxxx> wrote:
struct _myval
{
long idx;
std::string src_val;
std::string dst_val;
} myval;
list<_myval> g_myval;
std::string::iterator it = std::find (g_myval.begin(), g_myval.end(),
"hello");
Say I 'd to get src_val from the find function, what should I do?
You need to either define operator==(const _myval&, const string&) that
would compare the struct's src_val field to a given string, or else
write a comparison predicate doing the same and use find_if.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: how do I find an item in std::list?
- From: Jack
- Re: how do I find an item in std::list?
- From: Jack
- Re: how do I find an item in std::list?
- References:
- how do I find an item in std::list?
- From: Jack
- Re: how do I find an item in std::list?
- From: Igor Tandetnik
- Re: how do I find an item in std::list?
- From: Jack
- how do I find an item in std::list?
- Prev by Date: Changes to stdlib.h from ver. 6.0 to ver. 8.0
- Next by Date: Re: Changes to stdlib.h from ver. 6.0 to ver. 8.0
- Previous by thread: Re: how do I find an item in std::list?
- Next by thread: Re: how do I find an item in std::list?
- Index(es):
Relevant Pages
|