0

如何在自己的函数/方法中接收迭代器对?

void moveMessages(const std::InputIterator<uint64_t> begin, const std::InputIterator<uint64_t> end, uint32_t to_folder_id, int32_t from_folder=-1);

我正在尝试这样,错误 gcc 不喜欢它.. 可能我错过了一些重要的东西..

我在某个地方找到了一个模板版本来执行此操作。没有模板可以做到这一点吗?接收“输入迭代器基类”作为参数可能已经足够了,但是如何做到这一点呢?

4

1 回答 1

2

我在某个地方找到了一个模板版本来执行此操作。

是的,就是这样。

template <typename InputIterator>
void moveMessages(InputIterator begin, InputIterator end, uint32_t to_folder_id, int32_t from_folder=-1);

没有模板可以做到这一点吗?

Not really. Different kinds of iterators are different, unrelated types, so you need a template to handle them polymorphically.

Probably its enogh to receive an "input iterator base class" as a parameter, but how to do this?

There is no base class. In fact, iterators are not necessarily class types at all: pointers can be used as iterators.

于 2013-08-30T09:22:24.530 回答