H
Hill
#include <iostream>
#include <algorithm>
#include <list>
template <class In> struct Iseq: public std:air<In, In>
{
Iseq(In i1, In i2):std:air<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
#include <algorithm>
#include <list>
template <class In> struct Iseq: public std:air<In, In>
{
Iseq(In i1, In i2):std:air<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