如何将 deque>>vector>>bytes 迭代到函数

How to iterate a deque>>vector>>bytes to a function

我需要能够调用一个函数来寻找复杂数据结构的迭代器(伪代码)vector::deque::vector(uint8_t)::迭代器。我需要能够用 deque::vector(uint8_t); 来调用它。我不知道如何 "iterate" 它。

在下面的代码段中,我尝试使用 someMoreBytes 双端队列结构调用 MyFunkyFunc 函数。

#include <cstdlib>
#include <vector>
#include <deque>
#include "stdint.h"

using namespace std;

void MyFunkyFunc(std::vector<std::deque<std::vector<uint8_t>>>::iterator itsIt)
{

}

int
main(int argc, char** argv)
{
    std::vector<std::deque<std::vector < uint8_t>>> bunchaBytes;
    std::deque<std::vector<uint8_t>> someMoreBytes;

    //... Put at least one element in bunchaBytes

    MyFunkyFunc(bunchaBytes.begin());
    MyFunkyFunc(someMoreBytes); // Problem is here

    return 0;
}

这个代码存根是一个接近原始的代码;我无法对 MyFunkyFunc 函数进行任何修改,因为它在我必须 link 的库中。非常感谢

如果我们假设 MyFunkyFunc 作为接受迭代器参数的模板正确实现:

template <typename I>
void MyFunkyFunc (I itsIt) {
    //...
}

然后,您可以只传递 someMoreBytes 的地址,因为向量的迭代器的行为与向量元素的地址相同。

MyFunkyFunc(&someMoreBytes);

否则,您将需要重新定义 someMoreBytes 为单个元素 vector,并传入 begin(),就像您对 bunchaBytes 所做的那样。