4#include <unordered_map>
10#define DELETE_COPY_CONSTRUCT(Object) Object(const Object& other) = delete
11#define DELETE_COPY_ASSN(Object) Object& operator=(const Object& other) = delete
13#define DELETE_MOVE_CONSTRUCT(Object) Object(Object&& other) = delete
14#define DELETE_MOVE_ASSN(Object) Object& operator=(Object&& other) = delete
16#define DELETE_BOTH_COPY(Object) \
17 DELETE_COPY_CONSTRUCT(Object); \
18 DELETE_COPY_ASSN(Object)
20#define DELETE_BOTH_MOVE(Object) \
21 DELETE_MOVE_CONSTRUCT(Object); \
22 DELETE_MOVE_ASSN(Object)
24#define DEFAULT_MOVE_CONSTRUCT(Object) Object(Object&& other) = default
25#define DEFAULT_MOVE_ASSN(Object) Object& operator=(Object&& other) = default
27#define DEFAULT_BOTH_MOVE(Object) \
28 DEFAULT_MOVE_CONSTRUCT(Object); \
29 DEFAULT_MOVE_ASSN(Object)
31#define EXPLICIT_COPY_METHOD(Object) \
32 Object copy() const { \
51#define EXPLICIT_COPY_DEFAULT_MOVE(Object) \
52 DELETE_COPY_ASSN(Object); \
53 DEFAULT_BOTH_MOVE(Object); \
54 EXPLICIT_COPY_METHOD(Object)
58#define DELETE_COPY_DEFAULT_MOVE(Object) \
59 DELETE_BOTH_COPY(Object); \
60 DEFAULT_BOTH_MOVE(Object)
64#define DELETE_COPY_AND_MOVE(Object) \
65 DELETE_BOTH_COPY(Object); \
66 DELETE_BOTH_MOVE(Object)
70static std::vector<T> copyVector(
const std::vector<T>& objects) {
71 std::vector<T> result;
72 result.reserve(objects.size());
73 for (
auto&
object : objects) {
74 result.push_back(
object.copy());
80static std::vector<std::shared_ptr<T>> copyVector(
const std::vector<std::shared_ptr<T>>& objects) {
81 std::vector<std::shared_ptr<T>> result;
82 result.reserve(objects.size());
83 for (
auto&
object : objects) {
85 result.push_back(ob.copy());
91static std::vector<std::unique_ptr<T>> copyVector(
const std::vector<std::unique_ptr<T>>& objects) {
92 std::vector<std::unique_ptr<T>> result;
93 result.reserve(objects.size());
94 for (
auto&
object : objects) {
96 result.push_back(ob.copy());
101template<
typename K,
typename V>
102static std::unordered_map<K, V> copyUnorderedMap(
const std::unordered_map<K, V>& objects) {
103 std::unordered_map<K, V> result;
104 for (
auto& [k, v] : objects) {
105 result.insert({k, v.copy()});
110template<
typename K,
typename V>
111static std::map<K, V> copyMap(
const std::map<K, V>& objects) {
112 std::map<K, V> result;
113 for (
auto& [k, v] : objects) {
114 result.insert({k, v.copy()});