#pragma once // // This file is distributed under the MIT License. See LICENSE.md for details. // #include #include template class Range { private: using reference = typename Iterator::reference; using const_reference = typename Iterator::const_reference; using difference_type = typename Iterator::difference_type; public: Range(Iterator Begin, Iterator End) : Begin(Begin), End(End) {} template Range(ContainerT &&Container) : Begin(Container.begin()), End(Container.end()) {} Iterator begin() const { return Begin; } Iterator end() const { return End; } std::vector toVector() const { std::vector Result; for (auto Element : *this) Result.push_back(Element); return Result; } reference operator[](const difference_type &N) const { return Begin[N]; } difference_type size() const { return End - Begin; } private: Iterator Begin; Iterator End; }; template using rr = typename std::remove_reference::type; template using RangeFromContainer = Range::iterator>; template RangeFromContainer make_range(ContainerT &&Container) { return RangeFromContainer(Container); } template void copy(Range Source, OutputIterator Destination) { for (auto Element : Source) *Destination++ = Element; }