3#include <unordered_map>
9#define DELETE_COPY_CONSTRUCT(Object) Object(const Object& other) = delete
10#define DELETE_COPY_ASSN(Object) Object& operator=(const Object& other) = delete
12#define DELETE_MOVE_CONSTRUCT(Object) Object(Object&& other) = delete
13#define DELETE_MOVE_ASSN(Object) Object& operator=(Object&& other) = delete
15#define DELETE_BOTH_COPY(Object) \
16 DELETE_COPY_CONSTRUCT(Object); \
17 DELETE_COPY_ASSN(Object)
19#define DELETE_BOTH_MOVE(Object) \
20 DELETE_MOVE_CONSTRUCT(Object); \
21 DELETE_MOVE_ASSN(Object)
23#define DEFAULT_MOVE_CONSTRUCT(Object) Object(Object&& other) = default
24#define DEFAULT_MOVE_ASSN(Object) Object& operator=(Object&& other) = default
26#define DEFAULT_BOTH_MOVE(Object) \
27 DEFAULT_MOVE_CONSTRUCT(Object); \
28 DEFAULT_MOVE_ASSN(Object)
30#define EXPLICIT_COPY_METHOD(Object) \
31 Object copy() const { \
50#define EXPLICIT_COPY_DEFAULT_MOVE(Object) \
51 DELETE_COPY_ASSN(Object); \
52 DEFAULT_BOTH_MOVE(Object); \
53 EXPLICIT_COPY_METHOD(Object)
57#define DELETE_COPY_DEFAULT_MOVE(Object) \
58 DELETE_BOTH_COPY(Object); \
59 DEFAULT_BOTH_MOVE(Object)
63#define DELETE_COPY_AND_MOVE(Object) \
64 DELETE_BOTH_COPY(Object); \
65 DELETE_BOTH_MOVE(Object)
69static std::vector<T> copyVector(
const std::vector<T>& objects) {
70 std::vector<T> result;
71 result.reserve(objects.size());
72 for (
auto&
object : objects) {
73 result.push_back(
object.copy());
79static std::vector<std::shared_ptr<T>> copyVector(
const std::vector<std::shared_ptr<T>>& objects) {
80 std::vector<std::shared_ptr<T>> result;
81 result.reserve(objects.size());
82 for (
auto&
object : objects) {
84 result.push_back(ob.copy());
90static std::vector<std::unique_ptr<T>> copyVector(
const std::vector<std::unique_ptr<T>>& objects) {
91 std::vector<std::unique_ptr<T>> result;
92 result.reserve(objects.size());
93 for (
auto&
object : objects) {
95 result.push_back(ob.copy());
102static std::vector<std::unique_ptr<T>> cloneVector(
const std::vector<std::unique_ptr<T>>& objects) {
103 std::vector<std::unique_ptr<T>> result;
104 result.reserve(objects.size());
105 for (
auto&
object : objects) {
107 result.push_back(ob.clone());
112template<
typename K,
typename V>
113static std::unordered_map<K, V> copyMap(
const std::unordered_map<K, V>& objects) {
114 std::unordered_map<K, V> result;
115 for (
auto& [k, v] : objects) {
116 result.insert({k, v.copy()});