diff options
| author | Tyge Løvset <[email protected]> | 2023-02-18 07:51:44 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-18 07:51:44 +0100 |
| commit | 0e3d07dbd991c1f1a691b24655c37ddab660a9d9 (patch) | |
| tree | dc9801e2fc9f62cbe3eb32cc8897c65e3f25f78b /include | |
| parent | c4ae61de5be08e719e3183f4e2d1115c11856796 (diff) | |
| download | STC-modified-0e3d07dbd991c1f1a691b24655c37ddab660a9d9.tar.gz STC-modified-0e3d07dbd991c1f1a691b24655c37ddab660a9d9.zip | |
Fixed carc, cbox: no need for no_lookup and no_eq: use only no_cmp, no_hash if needed.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/carc.h | 12 | ||||
| -rw-r--r-- | include/stc/cbox.h | 12 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 4 | ||||
| -rw-r--r-- | include/stc/priv/template.h | 6 |
4 files changed, 24 insertions, 10 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h index 82f8835d..d606ac6e 100644 --- a/include/stc/carc.h +++ b/include/stc/carc.h @@ -77,6 +77,9 @@ int main() { #ifndef _i_prefix #define _i_prefix carc_ #endif +#ifdef i_eq +#define _i_eq +#endif #include "priv/template.h" typedef i_keyraw _cx_raw; @@ -180,7 +183,7 @@ STC_INLINE int _cx_memb(_cmp)(const _cx_self* x, const _cx_self* y) { } #endif -#ifndef i_no_eq +#ifdef _i_eq STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry) { return i_eq(rx, ry); } @@ -188,6 +191,12 @@ STC_INLINE bool _cx_memb(_eq)(const _cx_self* x, const _cx_self* y) { _cx_raw rx = i_keyto(x->get), ry = i_keyto(y->get); return i_eq((&rx), (&ry)); } +#elif !defined i_no_cmp +STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry) + { return i_cmp(rx, ry) == 0; } + +STC_INLINE bool _cx_memb(_eq)(const _cx_self* x, const _cx_self* y) + { return _cx_memb(_cmp)(x, y) == 0; } #endif #ifndef i_no_hash @@ -198,6 +207,7 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* x) { _cx_raw rx = i_keyto(x->get); return i_hash((&rx)); } #endif +#undef _i_eq #undef _i_atomic_inc #undef _i_atomic_dec_and_test #include "priv/template.h" diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 08449031..44c819dd 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -70,6 +70,9 @@ int main() { #ifndef _i_prefix #define _i_prefix cbox_ #endif +#ifdef i_eq +#define _i_eq +#endif #include "priv/template.h" typedef i_keyraw _cx_raw; @@ -166,7 +169,7 @@ STC_INLINE int _cx_memb(_cmp)(const _cx_self* x, const _cx_self* y) { } #endif -#ifndef i_no_eq +#ifdef _i_eq STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry) { return i_eq(rx, ry); } @@ -174,6 +177,12 @@ STC_INLINE bool _cx_memb(_eq)(const _cx_self* x, const _cx_self* y) { _cx_raw rx = i_keyto(x->get), ry = i_keyto(y->get); return i_eq((&rx), (&ry)); } +#elif !defined i_no_cmp +STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry) + { return i_cmp(rx, ry) == 0; } + +STC_INLINE bool _cx_memb(_eq)(const _cx_self* x, const _cx_self* y) + { return _cx_memb(_cmp)(x, y) == 0; } #endif #ifndef i_no_hash @@ -184,4 +193,5 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* x) { _cx_raw rx = i_keyto(x->get); return i_hash((&rx)); } #endif +#undef _i_eq #include "priv/template.h" diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index db9a2f5c..dae991ed 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -113,9 +113,7 @@ #define c_no_clone (1<<2) #define c_no_emplace (1<<3) #define c_no_cmp (1<<4) -#define c_no_eq (1<<5) -#define c_no_hash (1<<6) -#define c_no_lookup (c_no_cmp|c_no_eq|c_no_hash) +#define c_no_hash (1<<5) /* Function macros and others */ diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h index 4b5c60cf..3fddb998 100644 --- a/include/stc/priv/template.h +++ b/include/stc/priv/template.h @@ -99,9 +99,6 @@ #if c_option(c_no_cmp) #define i_no_cmp #endif -#if c_option(c_no_eq) - #define i_no_eq -#endif #if c_option(c_no_hash) #define i_no_hash #endif @@ -128,7 +125,7 @@ #elif defined i_keyboxed #define i_keyclass i_keyboxed #define i_rawclass c_PASTE(i_keyboxed, _raw) - #ifndef i_no_eq + #ifndef i_no_cmp #define i_eq c_PASTE(i_keyboxed, _raw_eq) #endif #endif @@ -338,7 +335,6 @@ #undef i_free #undef i_no_cmp -#undef i_no_eq #undef i_no_hash #undef i_no_clone #undef i_no_emplace |
