This repository was archived by the owner on Jan 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAlias.h
More file actions
56 lines (41 loc) · 1.26 KB
/
Alias.h
File metadata and controls
56 lines (41 loc) · 1.26 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <string>
#include <memory>
#include <vector>
#include <stack>
#include <map>
using String = std::string;
template<typename T>
using Vector = std::vector<T>;
template<typename T>
using Stack = std::stack<T>;
template<typename K, typename V>
using Map = std::map<K, V>;
template<typename T>
using UniquePtr = std::unique_ptr<T>;
template<typename T>
using SharedPtr = std::shared_ptr<T>;
template<typename T>
using SharedPtrVector = Vector<SharedPtr<T>>;
template<typename K, typename V>
using SharedPtrMap = Map<K, SharedPtr<V>>;
template<typename T, typename ...Args>
inline UniquePtr<T> makeUnique(Args &&...args) {
return std::make_unique<T>(std::forward<Args>(args)...);
}
template<typename T, typename ...Args>
inline SharedPtr<T> makeShared(Args &&...args) {
return std::make_shared<T>(std::forward<Args>(args)...);
}
template<typename T, typename P>
inline SharedPtr<T> staticPtrCast(const SharedPtr<P> &ptr) {
return std::static_pointer_cast<T>(ptr);
}
template<typename T, typename P>
inline SharedPtr<T> dynPtrCast(const SharedPtr<P> &ptr) {
return std::dynamic_pointer_cast<T>(ptr);
}
template<typename T, typename P>
inline SharedPtr<T> constPtrCast(const SharedPtr<P> &ptr) {
return std::const_pointer_cast<T>(ptr);
}