summaryrefslogtreecommitdiffhomepage
path: root/include/stc/carc.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-27 19:07:18 +0200
committerTyge Løvset <[email protected]>2022-04-27 19:07:18 +0200
commitedfcc712b48e2a582bcad1bc5a4102f18154e549 (patch)
tree70ed252f3bfd4e5841a25d802da630b73e58b800 /include/stc/carc.h
parentdf73eddd7933df7c96269f11e37fc1a96916f747 (diff)
downloadSTC-modified-edfcc712b48e2a582bcad1bc5a4102f18154e549.tar.gz
STC-modified-edfcc712b48e2a582bcad1bc5a4102f18154e549.zip
Final fixes to carc and cbox; Reverted constructor name to make; (similarity to make_shared/make_unique in c++).
Diffstat (limited to 'include/stc/carc.h')
-rw-r--r--include/stc/carc.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 02b932af..c7c18f53 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -103,14 +103,18 @@ _cx_memb(_from_ptr)(_cx_value* p) {
}
STC_INLINE _cx_self
-_cx_memb(_from)(i_key val) { // c++: std::make_shared<i_key>(val)
+_cx_memb(_make)(_cx_value val) { // c++: std::make_shared<_cx_value>(val)
_cx_self ptr; _cx_carc_rep *rep = c_alloc(_cx_carc_rep);
*(ptr.use_count = &rep->counter) = 1;
*(ptr.get = &rep->value) = val;
return ptr;
}
-STC_INLINE i_key _cx_memb(_toraw)(const _cx_self* self) {
+STC_INLINE _cx_raw _cx_memb(_toraw)(const _cx_self* self) {
+ return i_keyto(self->get);
+}
+
+STC_INLINE _cx_value _cx_memb(_get)(const _cx_self* self) {
return *self->get;
}
@@ -138,14 +142,16 @@ _cx_memb(_reset)(_cx_self* self) {
}
STC_INLINE void
-_cx_memb(_reset_from)(_cx_self* self, i_key val) {
+_cx_memb(_reset_to)(_cx_self* self, _cx_value* p) {
_cx_memb(_drop)(self);
- *self = _cx_memb(_from)(val);
+ *self = _cx_memb(_from_ptr)(p);
}
#if !defined _i_no_clone && !defined _i_no_emplace
STC_INLINE _cx_self
- _cx_memb(_make)(_cx_raw raw) { return _cx_memb(_from)(i_keyfrom(raw)); }
+ _cx_memb(_from)(_cx_raw raw) {
+ return _cx_memb(_make)(i_keyfrom(raw));
+ }
#endif // !_i_no_clone
// does not use i_keyclone, so OK to always define.