summaryrefslogtreecommitdiffhomepage
path: root/include/stc/priv
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-06-29 09:32:39 +0200
committerTyge Lovset <[email protected]>2023-06-29 10:48:03 +0200
commit764d6b5a831c4ff58fb717a1360fe80f691a424d (patch)
tree55b0353d1952f749dc34d4286b25970de4039545 /include/stc/priv
parent5096c3c951f6b99e9d6ee04a21531e226153cca9 (diff)
downloadSTC-modified-764d6b5a831c4ff58fb717a1360fe80f691a424d.tar.gz
STC-modified-764d6b5a831c4ff58fb717a1360fe80f691a424d.zip
Usage change: comparison is no longer enabled when specifying i_val for cvec, cdeq and clist (like cstack and cqueue). Comparison functions are still required when specifying i_valclass. For fundamental/native types like integers, floats etc., define i_native_cmp along with i_val instead of i_less/i_cmp/i_eq.
Diffstat (limited to 'include/stc/priv')
-rw-r--r--include/stc/priv/template.h53
-rw-r--r--include/stc/priv/template2.h5
2 files changed, 31 insertions, 27 deletions
diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h
index c1b7c1e7..03c27bdb 100644
--- a/include/stc/priv/template.h
+++ b/include/stc/priv/template.h
@@ -102,12 +102,6 @@
#if c_option(c_no_emplace)
#define i_no_emplace
#endif
-#ifdef i_eq
- #define _i_has_eq
-#endif
-#if defined i_cmp || defined i_less
- #define _i_has_cmp
-#endif
#if defined i_key_str
#define i_keyclass cstr
@@ -155,10 +149,10 @@
#endif
#ifdef i_rawclass
- #if !defined i_cmp && !defined i_no_cmp
+ #if !(defined i_cmp || defined i_no_cmp)
#define i_cmp c_PASTE(i_keyraw, _cmp)
#endif
- #if !defined i_hash && !defined i_no_hash
+ #if !(defined i_hash || defined i_no_hash || defined i_no_cmp)
#define i_hash c_PASTE(i_keyraw, _hash)
#endif
#endif
@@ -176,7 +170,7 @@
#ifndef i_tag
#define i_tag i_key
#endif
-#if c_option(c_no_clone)
+#if c_option(c_no_clone) || defined _i_carc
#define i_no_clone
#elif !(defined i_keyclone || defined i_no_clone) && (defined i_keydrop || defined i_keyraw)
#error i_keyclone/valclone should be defined when i_keydrop/valdrop or i_keyraw/valraw is defined
@@ -199,24 +193,33 @@
#define i_keydrop c_default_drop
#endif
-// i_eq, i_less, i_cmp
-#if !defined i_eq && (defined i_cmp || defined i_less)
- #define i_eq(x, y) !(i_cmp(x, y))
-#elif !defined i_eq
- #define i_eq c_default_eq
-#endif
-#if defined i_less && defined i_cmp
- #error "Only one of i_less and i_cmp may be defined"
-#elif !defined i_less && !defined i_cmp
- #define i_less c_default_less
-#elif !defined i_less
- #define i_less(x, y) (i_cmp(x, y)) < 0
-#endif
-#ifndef i_cmp
- #define i_cmp(x, y) (i_less(y, x)) - (i_less(x, y))
+#ifndef i_no_cmp
+ #if c_option(c_native_cmp) || defined i_native_cmp || defined i_cmp || defined i_less
+ #define _i_has_cmp
+ #endif
+ #if defined i_eq
+ #define _i_has_eq
+ #endif
+
+ // i_eq, i_less, i_cmp
+ #if !defined i_eq && (defined i_cmp || defined i_less)
+ #define i_eq(x, y) !(i_cmp(x, y))
+ #elif !defined i_eq
+ #define i_eq(x, y) *x == *y
+ #endif
+ #if defined i_cmp && defined i_less
+ #error "Only one of i_cmp and i_less may be defined"
+ #elif defined i_cmp
+ #define i_less(x, y) (i_cmp(x, y)) < 0
+ #elif !defined i_less
+ #define i_less(x, y) *x < *y
+ #endif
+ #ifndef i_cmp
+ #define i_cmp(x, y) (i_less(y, x)) - (i_less(x, y))
+ #endif
#endif
-#ifndef i_hash
+#if !(defined i_hash || defined _i_cbox || defined _i_carc)
#define i_hash c_default_hash
#endif
diff --git a/include/stc/priv/template2.h b/include/stc/priv/template2.h
index 47b82937..bd8bc5fc 100644
--- a/include/stc/priv/template2.h
+++ b/include/stc/priv/template2.h
@@ -67,6 +67,7 @@
#undef i_realloc
#undef i_free
+#undef i_native_cmp
#undef i_no_cmp
#undef i_no_hash
#undef i_no_clone
@@ -74,9 +75,9 @@
#undef i_is_forward
#undef i_has_emplace
+#undef _i_has_cmp
+#undef _i_has_eq
#undef _i_prefix
#undef _i_expandby
-#undef _i_has_eq
-#undef _i_has_cmp
#undef _i_template
#endif