diff options
| author | Tyge Løvset <[email protected]> | 2022-03-24 23:25:16 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-03-24 23:25:16 +0100 |
| commit | 233e354798d19dbac03ee0ff9c5e366bfefead6c (patch) | |
| tree | 153f8c3c3e0a0193af828cba81d2f7a16e6eb442 /include/stc/cbox.h | |
| parent | 0468971b404cee5582d360d7d1c66bb4148e1614 (diff) | |
| download | STC-modified-233e354798d19dbac03ee0ff9c5e366bfefead6c.tar.gz STC-modified-233e354798d19dbac03ee0ff9c5e366bfefead6c.zip | |
Misc. small internal API renaming/refactoring and additions.
Diffstat (limited to 'include/stc/cbox.h')
| -rw-r--r-- | include/stc/cbox.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 7b1cf377..fe4bca9d 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -85,14 +85,13 @@ STC_INLINE _cx_self _cx_memb(_from_ptr)(i_val* p) { return c_make(_cx_self){p}; }
STC_INLINE _cx_self
-_cx_memb(_from)(i_val val) {
- return c_make(_cx_self){c_new(i_val, val)};
+_cx_memb(_from)(i_val val) { // c++: std::make_unique<i_val>(val)
+ _cx_self ptr = {c_alloc(i_val)};
+ *ptr.get = val; return ptr;
}
STC_INLINE i_val
-_cx_memb(_toraw)(const _cx_self* self) {
- return *self->get;
-}
+_cx_memb(_toraw)(const _cx_self* self) { return *self->get; }
// destructor
STC_INLINE void
@@ -121,9 +120,7 @@ _cx_memb(_reset_from)(_cx_self* self, i_val val) { #if !c_option(c_no_clone)
#if !defined _i_no_raw
STC_INLINE _cx_self
- _cx_memb(_new)(_cx_raw raw) {
- return c_make(_cx_self){c_new(i_val, i_valfrom(raw))};
- }
+ _cx_memb(_new)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
#endif
STC_INLINE _cx_self
|
