explicit variable_for_loop(std::vector<std::reference_wrapper<IterableType>> collections)
{
// All collections should be non-empty: if one is empty, the
// for-loop has no effect (since there would be no way to choose
// one element from the empty collection(s))
const auto has_effect =
explicit variable_for_loop(std::vector<std::reference_wrapper<IterableType>> collections)
{
// All collections should be non-empty: if one is empty, the
// for-loop has no effect (since there would be no way to choose
// one element from the empty collection(s))
const auto has_effect =
}
// Otherwise leave `underlying_collections` as default-initialized (i.e. empty)
}
private:
std::vector<std::reference_wrapper<IterableType>> underlying_collections;
}
// Otherwise leave `underlying_collections` as default-initialized (i.e. empty)
}
private:
std::vector<std::reference_wrapper<IterableType>> underlying_collections;
std::vector<underlying_iterator> current_subset;
// boost::iterator_facade<...> interface to implement
std::vector<underlying_iterator> current_subset;
// boost::iterator_facade<...> interface to implement
// Attempt to move to the next element of the `j`th collection
const auto& new_position = ++current_subset[j];
// If the `j`th element has reached its own end, reset it
// back to the beginning and keep moving forward
// Attempt to move to the next element of the `j`th collection
const auto& new_position = ++current_subset[j];
// If the `j`th element has reached its own end, reset it
// back to the beginning and keep moving forward
- if (new_position == underlying_collections[j].end()) {
- current_subset[j] = underlying_collections[j].begin();
+ if (new_position == underlying_collections[j].get().end()) {
+ current_subset[j] = underlying_collections[j].get().begin();