summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-05-12 14:17:28 +0200
committerTyge Løvset <[email protected]>2022-05-12 14:17:28 +0200
commite2fad76fa778dc6bc041e2163615f230ae069f6b (patch)
tree1e92301036f197e9aaee6239263cc2c059efb1e2 /include
parent4186f2dc2d79318c664f1a55d9f9e790ca5e7f3b (diff)
downloadSTC-modified-e2fad76fa778dc6bc041e2163615f230ae069f6b.tar.gz
STC-modified-e2fad76fa778dc6bc041e2163615f230ae069f6b.zip
Fixed issues with i_keyfrom/i_valfrom
Diffstat (limited to 'include')
-rw-r--r--include/stc/cdeq.h12
-rw-r--r--include/stc/cvec.h1
-rw-r--r--include/stc/template.h28
3 files changed, 19 insertions, 22 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 77d2cf71..397186c9 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -81,18 +81,16 @@ STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) {
_cx_memb(_drop)(self); *self = _cx_memb(_clone)(other);
}
#endif // !_i_no_clone
-STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return !cdeq_rep_(&cx)->size; }
STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cdeq_rep_(&cx)->size; }
STC_INLINE size_t _cx_memb(_capacity)(_cx_self cx) { return cdeq_rep_(&cx)->cap; }
-STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) {c_swap(_cx_self, *a, *b); }
-STC_INLINE i_key _cx_memb(_value_fromraw)(i_keyraw raw) { return i_keyfrom(raw); }
+STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return !cdeq_rep_(&cx)->size; }
STC_INLINE i_keyraw _cx_memb(_value_toraw)(_cx_value* pval) { return i_keyto(pval); }
-
-STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) // == _pop() when _i_queue
- { i_keydrop(self->data); ++self->data; --cdeq_rep_(self)->size; }
+STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); }
+STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return self->data; }
STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self)
{ return self->data + cdeq_rep_(self)->size - 1; }
-STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return self->data; }
+STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) // == _pop() when _i_queue
+ { i_keydrop(self->data); ++self->data; --cdeq_rep_(self)->size; }
STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self)
{ return c_make(_cx_iter){self->data}; }
STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self)
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 488fa9cb..180bff32 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -99,7 +99,6 @@ STC_API _cx_value* _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos,
const _cx_value* p1, const _cx_value* p2);
STC_INLINE i_key _cx_memb(_value_clone)(_cx_value val)
{ return i_keyclone(val); }
-STC_INLINE i_key _cx_memb(_value_fromraw)(i_keyraw raw) { return i_keyfrom(raw); }
STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) {
if (self->data == other.data) return;
_cx_memb(_drop)(self);
diff --git a/include/stc/template.h b/include/stc/template.h
index 2082d509..2d01c68f 100644
--- a/include/stc/template.h
+++ b/include/stc/template.h
@@ -145,8 +145,8 @@
#if !defined i_key
#error "no i_key or i_val provided"
-#elif defined i_keyraw ^ (defined i_keyfrom || defined i_keyto)
- #error "if i_keyraw is defined, i_keyfrom and i_keyto must be defined, and vice versa"
+#elif defined i_keyraw ^ defined i_keyto
+ #error "if i_keyraw is defined, i_keyto must be defined, and vice versa"
#elif defined i_from || defined i_drop
#error "i_from / i_drop are not supported. Define i_keyfrom/i_valfrom and-or i_keydrop/i_valdrop instead."
#endif
@@ -157,13 +157,13 @@
#if c_option(c_no_clone) || (!defined i_keyclone && (defined i_keydrop || defined i_keyraw))
#define _i_no_clone
#endif
-#ifndef i_keyfrom
- #define i_keyfrom c_default_from
-#endif
#ifndef i_keyraw
#define i_keyraw i_key
+#endif
+#ifndef i_keyfrom
+ #define i_keyfrom c_default_from
#else
- #define _i_has_raw
+ #define _i_has_from
#endif
#ifndef i_keyto
#define i_keyto c_default_toraw
@@ -225,20 +225,20 @@
#endif
#endif
-#if defined i_valraw ^ (defined i_valfrom || defined i_valto)
- #error "if i_valraw is defined, i_valfrom and i_valto must be defined, and vice versa"
+#if defined i_valraw ^ defined i_valto
+ #error "if i_valraw is defined, i_valto must be defined, and vice versa"
#endif
#if !defined i_valclone && (defined i_valdrop || defined i_valraw)
#define _i_no_clone
#endif
-#ifndef i_valfrom
- #define i_valfrom c_default_from
-#endif
#ifndef i_valraw
#define i_valraw i_val
+#endif
+#ifndef i_valfrom
+ #define i_valfrom c_default_from
#else
- #define _i_has_raw
+ #define _i_has_from
#endif
#ifndef i_valto
#define i_valto c_default_toraw
@@ -258,7 +258,7 @@
#ifndef i_valraw
#define i_valraw i_keyraw
#endif
-#ifndef _i_has_raw
+#ifndef _i_has_from
#define _i_no_emplace
#endif
@@ -297,7 +297,7 @@
#undef i_keydrop
#undef _i_prefix
-#undef _i_has_raw
+#undef _i_has_from
#undef _i_key_from_val
#undef _i_no_clone
#undef _i_no_emplace