This does not work out of box:
std::vector<int> a{1,2,3};
std::vector<int> b{2,3,4};
for (auto [f, s] : boost::combine(a, b)) {
std::cout << f << ' ' << s << std::endl;
}
But this answer contains a quite small fragment of C++ code that suddenly makes this to work.
namespace std {
template <typename T, typename U>
struct tuple_size<boost::tuples::cons<T, U>>
: boost::tuples::length<boost::tuples::cons<T, U>>
{ };
template <size_t I, typename T, typename U>
struct tuple_element<I, boost::tuples::cons<T, U>>
: boost::tuples::element<I, boost::tuples::cons<T, U>>
{ };
}
The author, however, advises against using it in production.
Can this fragment crash my code under any circumstances, or it is just some organizational reason not to use this way to iterate over the loop?