From 684017fc495c797046ca1afdb4df12a5289005d1 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 20 Apr 2022 22:31:57 +0200 Subject: Minor adjustments. --- include/stc/alt/cstr.h | 5 +++++ include/stc/ccommon.h | 16 +++++++++------- include/stc/template.h | 6 ++++++ 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'include') 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 -- cgit v1.2.3