The problem with doing this for std::pair is that it "works" on a lot of things that are not valid ranges. Therefore, errors occur.
C ++ 11 does not have a built-in solution for this. You can use the Boost.Range make_iterator_range tool for easy creation . On the other hand, this is not entirely difficult to do manually:
template<typename T> class IterRange { T start; T end; public: IterRange(const T &start_, const T &end_) : start(start_), end(end_) {} T begin() {return start;} T end() {return end;} }; template<typename T> IterRange<T> make_range(const T &start, const T &end) {return IterRange<T>(start, end);}
source share