diff options
| author | Tyge Løvset <[email protected]> | 2022-04-20 22:31:57 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-20 22:31:57 +0200 |
| commit | 684017fc495c797046ca1afdb4df12a5289005d1 (patch) | |
| tree | 10842fc32cd7381cd3cc3c971111ffac500dbb42 | |
| parent | b06500c3920ae7ec56489d4dfe05f6a33af85a31 (diff) | |
| download | STC-modified-684017fc495c797046ca1afdb4df12a5289005d1.tar.gz STC-modified-684017fc495c797046ca1afdb4df12a5289005d1.zip | |
Minor adjustments.
| -rw-r--r-- | include/stc/alt/cstr.h | 5 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 16 | ||||
| -rw-r--r-- | include/stc/template.h | 6 |
3 files changed, 20 insertions, 7 deletions
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h index 409a7149..d6fed8e6 100644 --- a/include/stc/alt/cstr.h +++ b/include/stc/alt/cstr.h @@ -253,6 +253,11 @@ STC_INLINE void cstr_insert_s(cstr* self, size_t pos, cstr s) { STC_INLINE bool cstr_getline(cstr *self, FILE *fp)
{ return cstr_getdelim(self, '\n', fp); }
+/* container adaptor functions: */
+#define cstr_cmp(xp, yp) strcmp(cstr_str(xp), cstr_str(yp))
+#define cstr_eq(xp, yp) (!cstr_cmp(xp, yp))
+#define cstr_hash(xp, dummy) c_strhash(cstr_str(xp))
+
/* -------------------------- IMPLEMENTATION ------------------------- */
#if defined(_i_implement)
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 4ee6cad0..d7351611 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -93,13 +93,15 @@ #define c_default_drop(ptr) ((void) (ptr))
#define c_option(flag) ((i_opt) & (flag))
-#define c_is_fwd 1
-#define c_no_atomic 2
-#define c_no_clone 4
-#define c_no_cmp 8
-#define c_static 16
-#define c_header 32
-#define c_implement 64
+#define c_is_fwd (1<<0)
+#define c_no_atomic (1<<1)
+#define c_no_clone (1<<2)
+#define c_no_cmp (1<<3)
+#define c_hash (1<<4)
+#define c_eq (1<<5)
+#define c_static (1<<6)
+#define c_header (1<<7)
+#define c_implement (1<<8)
/* Generic algorithms */
diff --git a/include/stc/template.h b/include/stc/template.h index 1c63a096..d56ce1ce 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -133,6 +133,12 @@ #if !defined i_cmp && !defined i_key
#define i_cmp c_paste(i_valraw, _cmp)
#endif
+ #if !defined i_hash && c_option(c_hash)
+ #define i_hash c_paste(i_val, _hash)
+ #endif
+ #if !defined i_eq && c_option(c_eq)
+ #define i_eq c_paste(i_val, _eq)
+ #endif
#ifndef i_valdrop
#define i_valdrop c_paste(i_val, _drop)
#endif
|
