-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathutils.h
More file actions
35 lines (29 loc) · 835 Bytes
/
utils.h
File metadata and controls
35 lines (29 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef UTILS_H
#define UTILS_H
#include <string>
namespace utils {
bool DownloadFile(const std::string& url, const std::string& path);
template <typename I>
struct iter {
iter(I iterator) : base_iterator(iterator), index(0) {}
bool operator!=(const iter& other) const {
return base_iterator != other.base_iterator;
}
auto operator*() const { return std::make_pair(index, *base_iterator); }
const iter& operator++() {
++index;
++base_iterator;
return *this;
}
I base_iterator;
size_t index;
};
template <typename C>
struct enumerate {
enumerate(C& container) : container(container) {}
auto begin() { return iter<typename C::iterator>(std::begin(container)); }
auto end() { return iter<typename C::iterator>(std::end(container)); }
C& container;
};
} // namespace utils
#endif // UTILS_H