简体   繁体   English

如何在方法中接收迭代器对?

[英]How to receive a iterator pair in a method?

How can I receive a iterator pair in my own function/method? 如何在我自己的函数/方法中接收迭代器对?

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

Im trying like this, bug gcc dont like it.. Probably i am missing something important.. 我试着这样,bug gcc不喜欢它..可能我错过了一些重要的东西..

I found somewhere a template version to do this. 我找到了一个模板版本来做到这一点。 It is possible to do this without templates? 没有模板可以做到这一点吗? Probably its enogh to receive an "input iterator base class" as a parameter, but how to do this? 可能它的enogh接收“输入迭代器基类”作为参数,但如何做到这一点?

I found somewhere a template version to do this. 我找到了一个模板版本来做到这一点。

Yes, that's how to do it. 是的,这是怎么做的。

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

It is possible to do this without templates? 没有模板可以做到这一点吗?

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? 可能它的enogh接收“输入迭代器基类”作为参数,但如何做到这一点?

There is no base class. 没有基类。 In fact, iterators are not necessarily class types at all: pointers can be used as iterators. 实际上,迭代器根本不一定是类类型:指针可以用作迭代器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM