summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cvec.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-11-24 22:56:09 +0100
committerTyge Løvset <[email protected]>2021-11-24 22:56:09 +0100
commit9da78656f7b4a756dad2bf1c285a61a5186fd5ae (patch)
treed40af7ad57aa5d2468f45028937d0b7aaefd2080 /include/stc/cvec.h
parentb24cf706b9bbaff0eb97d9663e43a1e5e065ab83 (diff)
downloadSTC-modified-9da78656f7b4a756dad2bf1c285a61a5186fd5ae.tar.gz
STC-modified-9da78656f7b4a756dad2bf1c285a61a5186fd5ae.zip
Deprecated c_no_compare(). Define i_cmp_none instead when you have/want no element comparison for cvec, cdeq, clist, csptr. Will give compile time error if functions depending on comparisons are used.
Diffstat (limited to 'include/stc/cvec.h')
-rw-r--r--include/stc/cvec.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 5b58dca7..5e9a9877 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -84,9 +84,11 @@ STC_API void _cx_memb(_del)(_cx_self* self);
STC_API void _cx_memb(_clear)(_cx_self* self);
STC_API bool _cx_memb(_reserve)(_cx_self* self, const size_t cap);
STC_API bool _cx_memb(_resize)(_cx_self* self, const size_t size, i_val fill_val);
+#ifndef i_cmp_none
STC_API int _cx_memb(_value_compare)(const _cx_value* x, const _cx_value* y);
STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw raw);
STC_API _cx_iter _cx_memb(_bsearch_in)(_cx_iter it1, _cx_iter it2, i_valraw raw);
+#endif
STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value);
STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2);
STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos,
@@ -192,6 +194,8 @@ _cx_memb(_at)(const _cx_self* self, const size_t idx) {
return self->data + idx;
}
+#ifndef i_cmp_none
+
STC_INLINE _cx_iter
_cx_memb(_find)(const _cx_self* self, i_valraw raw) {
return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw);
@@ -221,7 +225,7 @@ STC_INLINE void
_cx_memb(_sort)(_cx_self* self) {
_cx_memb(_sort_range)(_cx_memb(_begin)(self), _cx_memb(_end)(self), _cx_memb(_value_compare));
}
-
+#endif // !i_cmp_none
/* -------------------------- IMPLEMENTATION ------------------------- */
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
@@ -339,6 +343,7 @@ _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) {
return c_make(_cx_iter){.ref = p1};
}
+#ifndef i_cmp_none
STC_DEF _cx_iter
_cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, i_valraw raw) {
for (; i1.ref != i2.ref; ++i1.ref) {
@@ -367,7 +372,7 @@ _cx_memb(_value_compare)(const _cx_value* x, const _cx_value* y) {
i_valraw ry = i_valto(y);
return i_cmp(&rx, &ry);
}
-
+#endif // !i_cmp_none
#endif
#include "template.h"
#define CVEC_H_INCLUDED