473,549 Members | 3,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question on std::find()

I have the ff code:

list<string> *m_alive_list ;
list<string>::i terator my_iter;
my_iter = find(m_alive_li st->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 3688
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_li st->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>::i terator 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_li st->begin(), m_alive_list->end, string(inbox) );


And what about the _other_ obvious typo?

Try

my_iter = find(m_alive_li st->begin(),m_aliv e_list->end(),string(i nbox));

Apr 24 '06 #7


Markus Schoder wrote:

And what about the _other_ obvious typo?

Try

my_iter = find(m_alive_li st->begin(),m_aliv e_list->end(),string(i nbox));


<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
12804
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 function find() and I have to use std::find(). The linker fails on unsatisified symbols in find(). I think this is because find() is a template...
3
1806
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 headers the implementation is: template <class InputIterator, class T> InputIterator find (InputIterator first, InputIterator last, const T& value)
1
2199
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> allVertices ; getTriangleVertices(t, allVertices) ; //Fills the allVertices vector getTriangleVertices(t, allVertices) ; print("All Vertices",...
18
7176
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 <bitset> using std::vector;
8
8622
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
5519
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 match on doubles? second: if yes, how may this be done (i.e. how many one specify the tolerance threshold for comparing doubles?)
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7718
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.