Closed Talkless closed 2 years ago
Is there a way to avoid Foo copies, i.e. make it a reference to const?
Yes, don't ask for copies here:
for (const auto i:
// ~~~~^
You meant const auto&
.
Oh boy, no that was quite embarrassing... Thanks @brevzin , and sorry for the noise.
Here's simple example (try https://godbolt.org/z/5nM9jr4Gb):
Application prints:
So we see that filtering produce additional Foo copy during filtering (after initializing vector).
If we uncomment line
//typename decltype(pair)::typeof is;
we discover thatpair
's type is:Is there a way to avoid Foo copies, i.e. make it a reference to const? Imagine if second zipped range is vector of vectors, and this behavior means copying of that vector on every filter()'ing?