Open ryanhaining opened 7 years ago
std::optional
doesn't support reference types. I can use a std::optional<std::reference_wrapper<T>>
but that'll throw off uses with assignment
Is it possible to replace boost::optional with C Pointers in zip_longest?
I can't imagine how, do you have something in mind?
#include <zip_longest.hpp>
#include <vector>
#include <string>
#include <iostream>
int main() {
std::vector<int> ivec{1, 4, 9, 16, 25, 36};
std::vector<std::string> svec{"hello", "good day", "goodbye"};
// i: int*
// s: std::string*
for (auto&& [i, s] : iter::zip_longest(ivec, svec)) {
if (i) {
std::cout << *i << std::endl;
}
if (s) {
std::cout << *s << std::endl;
}
}
}
of course you could implement a zip_longest
like that, but changes to the yielded type cannot break existing uses.
Changing the type to a pointer doesn't change the existing usage, does it?
I can't change the library in a way that breaks existing users if they update to a newer version of the library.