diff options
| author | Tyge Løvset <[email protected]> | 2022-09-02 23:45:11 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-02 23:45:11 +0200 |
| commit | 491a8cba3ee55a1200fc2de8ef3807dd8436f829 (patch) | |
| tree | f877ef241836ca369561cf62d2db465ef3cbeca0 /include/stc/cbox.h | |
| parent | a2a18a52df4fc10ad453eba7cdfbe2d02a026f0b (diff) | |
| download | STC-modified-491a8cba3ee55a1200fc2de8ef3807dd8436f829.tar.gz STC-modified-491a8cba3ee55a1200fc2de8ef3807dd8436f829.zip | |
Change: carc and cbox defaults to pointer comparison when none of i_cmp, i_less or i_eq is specified. This removes annoying requirement.
Diffstat (limited to 'include/stc/cbox.h')
| -rw-r--r-- | include/stc/cbox.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 02a73fdc..fc300de3 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -41,7 +41,6 @@ void Person_drop(Person* p) { } #define i_key_bind Person // bind Person clone+drop fn's -#define i_opt c_no_cmp // compare by .get addresses only #define i_type PBox #include <stc/cbox.h> @@ -71,6 +70,9 @@ int main() { #ifndef _i_prefix #define _i_prefix cbox_ #endif +#if !(defined i_cmp || defined i_less || defined i_eq || defined i_hash) + #define _i_no_cmp +#endif #include "template.h" typedef i_keyraw _cx_raw; @@ -147,7 +149,7 @@ STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self other) { } STC_INLINE uint64_t _cx_memb(_value_hash)(const _cx_value* x) { - #if c_option(c_no_cmp) + #if defined _i_no_cmp return c_default_hash(&x); #else _cx_raw rx = i_keyto(x); @@ -156,7 +158,7 @@ STC_INLINE uint64_t _cx_memb(_value_hash)(const _cx_value* x) { } STC_INLINE int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { - #if c_option(c_no_cmp) + #if defined _i_no_cmp return c_default_cmp(&x, &y); #else _cx_raw rx = i_keyto(x), ry = i_keyto(y); @@ -165,7 +167,7 @@ STC_INLINE int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { } STC_INLINE bool _cx_memb(_value_eq)(const _cx_value* x, const _cx_value* y) { - #if c_option(c_no_cmp) + #if defined _i_no_cmp return x == y; #else _cx_raw rx = i_keyto(x), ry = i_keyto(y); |
