<分区>
没有复制容器的数据是否可以做到这一点?
template<typename T> //we know only the type return by iterator
class Foo {
private:
I b; //or some base class of iterator or own generic iterator
I e; //what should be 'I'?
public:
template<typename I>
Foo(begin, end) {
b = begin;
e = end;
}
void find(T value) {
while(b != e) {
...
++b;
}
return NULL;
}
};
//...
//this can't be changed
std::vector<int> vec;
Foo<int> foo1(vec.begin(), vec.end());
std::list<double> list;
Foo<double> foo2(list.begin(), list.end());