#pragma once #include template std::vector> getPairs(const TCollection& collection) { using TElement = typename TCollection::value_type; using TPair = std::pair; auto begin = collection.begin(); auto end = collection.end(); if (begin == end || ++TCollection::const_iterator(begin) == end) { return std::vector(); } std::vector result; for (auto first = begin, second = ++TCollection::const_iterator(begin); second != end; ++first, ++second) { result.push_back(TPair(*first, *second)); } return result; }