Closed kiwwisk closed 5 years ago
Hello, as fist step, thanks for this great library!
Now with the issue:
std::vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8}; auto f = iter::enumerate(v) | iter::filter([](auto& i) { return std::get<1>(i) > 4; }); for (auto&& [i, e]: f) { std::cout << i << ", " << e << '\n'; }
This snippet doesn't compile (g++ 7.4), with error:
error: use of deleted function ‘std::optional<iter::impl::EnumIterYield<long unsigned int, int&> >& std::optional<iter::impl::EnumIterYield<long unsigned int, int&> >::operator=(std::optional<iter::impl::EnumIterYield<long unsigned int, int&> >&&)’
I opened StackOverflow question, since I'm not sure if I didn't do something wrong - https://stackoverflow.com/questions/57648457/cppitertools-how-to-combine-iterenumerate-and-iterfilter
Is it possible to combine filter with enumerate this way? The solutions appears is to change iterbase.hpp:301 from item_p_ = std::move(item); to item_p_.emplace(std::move(item));
iterbase.hpp:301
item_p_ = std::move(item);
item_p_.emplace(std::move(item));
Thank you for taking the time to produce an MCVE for this. The suggest fix from Piotr Skotnicki is indeed correct and I just pushed a fix.
Hello, as fist step, thanks for this great library!
Now with the issue:
This snippet doesn't compile (g++ 7.4), with error:
I opened StackOverflow question, since I'm not sure if I didn't do something wrong - https://stackoverflow.com/questions/57648457/cppitertools-how-to-combine-iterenumerate-and-iterfilter
Is it possible to combine filter with enumerate this way? The solutions appears is to change
iterbase.hpp:301
fromitem_p_ = std::move(item);
toitem_p_.emplace(std::move(item));