One compiling error.

H

Hill

#include <iostream>
#include <algorithm>
#include <list>
template <class In> struct Iseq: public std::pair<In, In>
{
Iseq(In i1, In i2):std::pair<In, In>(i1, i2){
}
};
template<class C> Iseq<typename C::iterator_type> iseq(C& c)
{
return Iseq<typename C::iterator_type>(c.begin(), c.end());
}

template <class In, class T>In myfind(Iseq<In> r, const T& v)
{
return std::find(r.first, r.second, v);
}
int main()
{
std::list<std::string> names;
names.push_back("Zhu");
names.push_back("Wu");
names.push_back("Wang");
std::cout<< myfind(iseq(names), "Wang");
}


-*- mode: compilation; default-directory: "d:/tcplex/p3_ch18/" -*-
Compilation started at Mon Dec 29 16:23:54

g++ 18.6_input_sequence.cpp
18.6_input_sequence.cpp: In function `int main()':
18.6_input_sequence.cpp:24: error: no matching function for call to
`iseq(std::list<std::string, std::allocator<std::string> >&)'

Compilation exited abnormally with code 1 at Mon Dec 29 16:23:54
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top