-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.hpp
More file actions
27 lines (20 loc) · 744 Bytes
/
util.hpp
File metadata and controls
27 lines (20 loc) · 744 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
/* See LICENSE file for copyright and license details. */
#pragma once
#include <string_view>
#include <utility>
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
struct Rect {
int x = 0, y = 0, width = 0, height = 0;
int getIntersection(const Rect& other) const;
};
template <typename Container, typename LocationIt>
inline void shuffleToFront(Container& container, LocationIt location) {
auto element = std::move(*location);
container.erase(location);
container.insert(container.begin(), std::move(element));
}
inline bool contains(const std::string_view haystack,
const std::string_view needle) {
return std::string_view::npos != haystack.find(needle);
}
void die(const char* fmt, ...);