You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, let me thank you the for this. Seems exactly what I'm looking for.
Have you considered what happens/should-happen if one of the containers are empty?
I get a crash when trying to work with that, e.g. as illustrated:
#include "product_iterator.hpp"
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> c1({1,2});
vector<char> c2; // NOTE THIS IS EMPTY!
auto it = make_product_iterator(c1, c2);
auto end = it.get_end();
for(; it != end; ++it)
{
cout << "{" << it.get<0>() << ", " << it.get<1>() << "}\n";
}
}
To allow client to use/test for that you could e.g. introduce a new method - similar to the get<>() - that tests for whether the container iterator is at its end, e.g. something like:
I've tried to add that (se snippet code below for usage), but it still crashes al beit after output the first expected combination. I haven't examined (yet) what is causing the crash, but likely it is related to how you advance iterators in your implementation.
First, let me thank you the for this. Seems exactly what I'm looking for.
Have you considered what happens/should-happen if one of the containers are empty?
I get a crash when trying to work with that, e.g. as illustrated:
To allow client to use/test for that you could e.g. introduce a new method - similar to the
get<>()
- that tests for whether the container iterator is at its end, e.g. something like:I've tried to add that (se snippet code below for usage), but it still crashes al beit after output the first expected combination. I haven't examined (yet) what is causing the crash, but likely it is related to how you advance iterators in your implementation.
Expected output:
Regards,
/Michael
The text was updated successfully, but these errors were encountered: