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? 7 3688
Correction - compiler barfs on the THIRD line (i.e. line containing the
find() algorithm)
Line 3.
1 - put () at end of end methode :)
2 - put ) at end of find function/template 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) );
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;
}
By-thw-way - what compiler do you use?
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));
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... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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)
|
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",...
|
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;
|
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
| |
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?)
|
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...
|
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. ...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |