473,378 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

question on std::find()

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
7 3680
Correction - compiler barfs on the THIRD line (i.e. line containing the
find() algorithm)

Apr 23 '06 #2
Line 3.

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

Apr 23 '06 #3


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
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
By-thw-way - what compiler do you use?

Apr 23 '06 #6
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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: zhou | last post by:
Hi there, We have a compiler specific issue which requires us to force template instantiation. This works fine. The problem comes when I try using std:find() on vector. Since vector has no member...
3
by: Old Wolf | last post by:
In the documentation for std::find, it says: find returns the first iterator i in the range [first, last) for which the following condition holds: *i == value. However in my compiler's...
1
by: Adam Teasdale Hartshorne | last post by:
I would be extremely grateful if somebody could tell me what as I getting wrong with this little bit of code to find the index of a particular element in a std::vector std::vector<int>...
18
by: ma740988 | last post by:
Trying to get more acclimated with the use of function objects. As part of my test, consider: # include <vector> # include <iostream> # include <algorithm> #include <stdexcept> #include...
8
by: brekehan | last post by:
If I have a class MyClass { ...bunch o data and methods int x; }; and a stl container of MyClass objects Is there a way to use std::find to get all the elements whose member x
4
by: Anonymous | last post by:
I ahve a vector of doubles taht I need to extract values from. I was just about to use the STL find() algo, but I have a couple of questions: first: can you specify the tolerance threshold to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.