36 lines
791 B
C++
36 lines
791 B
C++
#pragma once
|
|
|
|
#include <tuple>
|
|
|
|
namespace util {
|
|
|
|
template <int I, class... Ts>
|
|
decltype(auto) get(Ts&&... ts) {
|
|
return std::get<I>(std::forward_as_tuple(ts...));
|
|
}
|
|
|
|
template <class Iterator>
|
|
class Range {
|
|
Iterator m_begin, m_end;
|
|
|
|
public:
|
|
Range(const Iterator _begin, const Iterator _end)
|
|
: m_begin(_begin), m_end(_end) {}
|
|
|
|
Range(const std::pair<const Iterator, const Iterator>& t) {
|
|
m_begin = t.first;
|
|
m_end = t.second;
|
|
}
|
|
|
|
template <typename... Args>
|
|
Range(Args&&... args) : m_begin(get<0>(args...)), m_end(get<1>(args...)) {}
|
|
|
|
auto begin() -> Iterator { return m_begin; }
|
|
auto begin() const -> const Iterator { return m_begin; }
|
|
|
|
auto end() -> Iterator { return m_end; }
|
|
auto end() const -> const Iterator { return m_end; }
|
|
};
|
|
|
|
} // namespace util
|