File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,18 @@ struct Rc {
4545 }
4646
4747 template <typename ... Args>
48- requires Constructable<T, Args...>
4948 [[nodiscard]] static Rc make (Args&&... args) noexcept {
5049 Rc ret;
5150 ret.data_ = A::template make<Data>(static_cast <u64 >(1 ));
52- ret.data ->value .construct (forward<Args>(args)...);
51+ new (ret.data_ ->value .data ()) T{forward<Args>(args)...};
52+ return ret;
53+ }
54+
55+ static Rc from_this (T* value) noexcept {
56+ Rc ret;
57+ ret.data_ =
58+ reinterpret_cast <Data*>(reinterpret_cast <u8 *>(value) - RPP_OFFSETOF (Data, value));
59+ ret.data_ ->references ++;
5360 return ret;
5461 }
5562
@@ -136,11 +143,18 @@ struct Arc {
136143 }
137144
138145 template <typename ... Args>
139- requires Constructable<T, Args...>
140146 [[nodiscard]] static Arc make (Args&&... args) noexcept {
141147 Arc ret;
142148 ret.data_ = A::template make<Data>(Thread::Atomic{1 });
143- ret.data_ ->value .construct (forward<Args>(args)...);
149+ new (ret.data_ ->value .data ()) T{forward<Args>(args)...};
150+ return ret;
151+ }
152+
153+ static Arc from_this (T* value) noexcept {
154+ Arc ret;
155+ ret.data_ =
156+ reinterpret_cast <Data*>(reinterpret_cast <u8 *>(value) - RPP_OFFSETOF (Data, value));
157+ ret.data_ ->references .incr ();
144158 return ret;
145159 }
146160
Original file line number Diff line number Diff line change @@ -60,6 +60,13 @@ struct Storage {
6060 return reinterpret_cast <const T*>(value_);
6161 }
6262
63+ [[nodiscard]] const u8 * data () const noexcept {
64+ return value_;
65+ }
66+ [[nodiscard]] u8 * data () noexcept {
67+ return value_;
68+ }
69+
6370protected:
6471 alignas (alignof (T)) u8 value_[sizeof (T)];
6572
You can’t perform that action at this time.
0 commit comments