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