By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

question on std::find()

P: n/a
I have the ff code:

list<string> *m_alive_list ;
list<string>::iterator my_iter;
my_iter = find(m_alive_list->begin(), m_alive_list->end, string(inbox) ;

Compiler barfs on 2nd line with this error msg:

error C2665: 'std::find' : none of the 3 overloads can convert parameter
1 from type 'std::list<_Ty>::iterator'
with
[
_Ty=std::string
]

I thought the first arg (i.e. ->begin() ) returns an iterator of the
correct type - what gives?

Apr 23 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Correction - compiler barfs on the THIRD line (i.e. line containing the
find() algorithm)

Apr 23 '06 #2

P: n/a
Line 3.

1 - put () at end of end methode :)
2 - put ) at end of find function/template

Apr 23 '06 #3

P: n/a


pa**************@gmail.com wrote:
Line 3.

1 - put () at end of end methode :)
2 - put ) at end of find function/template


That was an obvious typo (did you read the compiler error message).

For those whom the typo was not obvious, here is the corrected line:

my_iter = find(m_alive_list->begin(), m_alive_list->end, string(inbox) );

Apr 23 '06 #4

P: n/a
I did not see any problems, here is my code that works;

#include <list>
#include <string>
#include <algorithm>

using namespace std;

list<string> *m_list ;
list<string>::iterator my_iter;

int main()
{
m_list = new list<string>;
my_iter = find(m_list->begin(), m_list->end(), string("dasdas")) ;

delete m_list;
return 0;
}

Apr 23 '06 #5

P: n/a
By-thw-way - what compiler do you use?

Apr 23 '06 #6

P: n/a
Bit byte wrote:
pa**************@gmail.com wrote:
Line 3.

1 - put () at end of end methode :)
2 - put ) at end of find function/template


That was an obvious typo (did you read the compiler error message).

For those whom the typo was not obvious, here is the corrected line:

my_iter = find(m_alive_list->begin(), m_alive_list->end, string(inbox) );


And what about the _other_ obvious typo?

Try

my_iter = find(m_alive_list->begin(),m_alive_list->end(),string(inbox));

Apr 24 '06 #7

P: n/a


Markus Schoder wrote:

And what about the _other_ obvious typo?

Try

my_iter = find(m_alive_list->begin(),m_alive_list->end(),string(inbox));


<echo>
Doh !!!!!!
</echo>

I think its time for another cofee break...

Apr 24 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.