File tree Expand file tree Collapse file tree 5 files changed +331
-1
lines changed Expand file tree Collapse file tree 5 files changed +331
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,20 @@ std::shared_ptr<T> to(std::shared_ptr<block> p) {
29
29
return ret;
30
30
}
31
31
32
+ template <typename T>
33
+ std::shared_ptr<T> clone (std::shared_ptr<T> p) {
34
+ if (!p) return nullptr ;
35
+ return to<T>(p->clone_impl ());
36
+ }
37
+
38
+ template <typename T>
39
+ std::shared_ptr<T> clone_obj (T* t) {
40
+ auto np = std::make_shared<T>();
41
+ np->static_offset = t->static_offset ;
42
+ np->metadata_map = t->metadata_map ;
43
+ return np;
44
+ }
45
+
32
46
template <typename T>
33
47
class block_metadata_impl ;
34
48
@@ -62,6 +76,8 @@ class block_metadata_impl : public block_metadata {
62
76
block_metadata_impl (T _val) : val(_val) {}
63
77
};
64
78
79
+
80
+
65
81
class block : public std ::enable_shared_from_this<block> {
66
82
public:
67
83
virtual ~block () = default ;
@@ -113,6 +129,11 @@ class block : public std::enable_shared_from_this<block> {
113
129
return false ;
114
130
return true ;
115
131
}
132
+
133
+ virtual block::Ptr clone_impl (void ) {
134
+ // abstract class always returns nullptr
135
+ return nullptr ;
136
+ }
116
137
};
117
138
} // namespace block
118
139
#endif
You can’t perform that action at this time.
0 commit comments