diff options
| author | Tyge Lovset <[email protected]> | 2022-04-18 12:12:01 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2022-04-18 12:12:01 +0200 |
| commit | b0d60c33a073782fe0bb08c835ca9db0b94145d0 (patch) | |
| tree | 1683369ec66467720502b3d904bf9ab11343076e /include/stc | |
| parent | 00804d9ff488f63468a0bb528c7b807aea7c3ea3 (diff) | |
| download | STC-modified-b0d60c33a073782fe0bb08c835ca9db0b94145d0.tar.gz STC-modified-b0d60c33a073782fe0bb08c835ca9db0b94145d0.zip | |
Removed i_drop and i_from template specifiers to reduce redundancies and add clarity (error given if used): use i_valdrop/i_valfrom and i_keydrop/i_keyfrom instead.
Added missing at_mut() function to cdeq.
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/cdeq.h | 10 | ||||
| -rw-r--r-- | include/stc/template.h | 20 |
2 files changed, 9 insertions, 21 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index baa7cb04..0dfe79dd 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -103,16 +103,16 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) #if !defined _i_queue
+STC_INLINE size_t _cx_memb(_index)(_cx_self cx, _cx_iter it)
+ { return it.ref - cx.data; }
STC_INLINE void _cx_memb(_pop_back)(_cx_self* self)
{ _cx_value* p = &self->data[--cdeq_rep_(self)->size]; i_valdrop(p); }
STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, const size_t idx) {
- assert(idx < cdeq_rep_(self)->size);
- return self->data + idx;
+ assert(idx < cdeq_rep_(self)->size); return self->data + idx;
}
-
-STC_INLINE size_t _cx_memb(_index)(_cx_self cx, _cx_iter it) {
- return it.ref - cx.data;
+STC_INLINE _cx_value* _cx_memb(_at_mut)(_cx_self* self, const size_t idx) {
+ assert(idx < cdeq_rep_(self)->size); return self->data + idx;
}
STC_INLINE _cx_iter
diff --git a/include/stc/template.h b/include/stc/template.h index 243eec6f..934a5d4a 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -97,21 +97,11 @@ #error "if i_keyraw defined, i_keyfrom (and often i_keyto) must be defined"
#endif
-/* Resolve i_drop and i_from here */
-#if defined i_drop && !defined i_keydrop && defined _i_isset
- #define i_keydrop i_drop
-#elif defined i_drop && !defined i_key
- #define i_valdrop i_drop
-#elif defined i_drop
- #error "i_drop not supported when i_key defined. Define i_keydrop/i_valdrop instead."
+#if defined i_drop
+ #error "i_drop not supported Define i_keydrop/i_valdrop instead."
#endif
-
-#if defined i_from && !defined i_keyfrom && defined _i_isset
- #define i_keyfrom i_from
-#elif defined i_from && !defined i_key
- #define i_valfrom i_from
-#elif defined i_from
- #error "i_from not supported when i_key defined. Define i_keyfrom/i_valfrom instead."
+#if defined i_from
+ #error "i_from not supported. Define i_keyfrom/i_valfrom instead."
#endif
#ifdef i_val_str
@@ -237,8 +227,6 @@ #undef i_cmp
#undef i_eq
#undef i_hash
-#undef i_from
-#undef i_drop
#undef i_size
#undef i_val
|
