summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cstack.h
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-05-19 19:06:37 +0200
committerTyge Lovset <[email protected]>2023-05-19 19:06:37 +0200
commitd629139d053fdc1ff24bc0dc1985e1a2d1a0ac47 (patch)
tree86af3209ee9f11d38cbb053ee658b0f2dae6565d /include/stc/cstack.h
parent424e522d6f081bb8649777a3376e1dd5913daac8 (diff)
downloadSTC-modified-d629139d053fdc1ff24bc0dc1985e1a2d1a0ac47.tar.gz
STC-modified-d629139d053fdc1ff24bc0dc1985e1a2d1a0ac47.zip
Added container equality function to docs _eq(c1, c2).
Diffstat (limited to 'include/stc/cstack.h')
-rw-r--r--include/stc/cstack.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/stc/cstack.h b/include/stc/cstack.h
index 84bdb41b..bee7d17b 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -194,4 +194,15 @@ STC_INLINE intptr_t _cx_memb(_index)(const _cx_self* self, _cx_iter it)
STC_INLINE void _cx_memb(_adjust_end_)(_cx_self* self, intptr_t n)
{ self->_len += n; }
+#if defined _i_has_eq || defined _i_has_cmp
+STC_INLINE bool
+_cx_memb(_eq)(const _cx_self* self, const _cx_self* other) {
+ if (self->_len != other->_len) return false;
+ for (intptr_t i = 0; i < self->_len; ++i) {
+ const _cx_raw _rx = i_keyto(self->data+i), _ry = i_keyto(other->data+i);
+ if (!(i_eq((&_rx), (&_ry)))) return false;
+ }
+ return true;
+}
+#endif
#include "priv/template2.h"