diff options
| author | Tyge Løvset <[email protected]> | 2022-04-19 12:12:55 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-19 12:12:55 +0200 |
| commit | ba6da4261792bd5da7da952877c299cd5c7a607b (patch) | |
| tree | bb80f8dfa108a3ccf92184b688ecb5a534ca8b5f /include | |
| parent | 58497293d88109624d4798c56e888bcbab7c4285 (diff) | |
| download | STC-modified-ba6da4261792bd5da7da952877c299cd5c7a607b.tar.gz STC-modified-ba6da4261792bd5da7da952877c299cd5c7a607b.zip | |
Added #error/warnings for likely missing definitions of i_hash/i_cmp.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cmap.h | 7 | ||||
| -rw-r--r-- | include/stc/template.h | 14 |
2 files changed, 16 insertions, 5 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 7834c9b0..106a140d 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -70,8 +70,13 @@ typedef struct { size_t idx; uint8_t hx; } chash_bucket_t; #define _i_keyref(vp) (&(vp)->first)
#endif
#include "template.h"
+#if _i_no_hash == 1
+ #error "i_hash must be defined if i_cmp, i_eq or i_keyfrom is defined for cmap/cset. For basic types c_default_hash may be used."
+#elif _i_no_hash == 2
+ #error "i_cmp or i_eq must be defined if i_hash is defined. For basic types c_default_cmp may be used."
+#endif
#if !c_option(c_is_fwd)
-_cx_deftypes(_c_chash_types, _cx_self, i_key, i_val, i_size, _i_MAP_ONLY, _i_SET_ONLY);
+ _cx_deftypes(_c_chash_types, _cx_self, i_key, i_val, i_size, _i_MAP_ONLY, _i_SET_ONLY);
#endif
_i_MAP_ONLY( struct _cx_value {
diff --git a/include/stc/template.h b/include/stc/template.h index 934a5d4a..e46b7390 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -94,11 +94,10 @@ #endif
#if defined i_keyraw && !defined i_keyfrom
- #error "if i_keyraw defined, i_keyfrom (and often i_keyto) must be defined"
+ #error "if i_keyraw is defined, i_keyfrom (and normally i_keyto) must be defined"
#endif
-
#if defined i_drop
- #error "i_drop not supported Define i_keydrop/i_valdrop instead."
+ #error "i_drop not supported. Define i_keydrop/i_valdrop instead."
#endif
#if defined i_from
#error "i_from not supported. Define i_keyfrom/i_valfrom instead."
@@ -138,7 +137,7 @@ #endif
#if defined i_valraw && !defined i_valfrom
- #error "if i_valraw defined, i_valfrom (and often i_valto) must be defined"
+ #error "if i_valraw is defined, i_valfrom (and normally i_valto) must be defined"
#endif
#if !defined i_keyraw && !defined i_valraw
@@ -174,6 +173,12 @@ #if !defined i_keyfrom && defined i_keydrop
#define _i_no_clone
#endif
+ #if !defined i_hash && (defined i_keyfrom || defined i_cmp || defined i_eq)
+ #define _i_no_hash 1
+ #endif
+ #if !defined i_cmp && !defined i_eq && defined i_hash
+ #define _i_no_hash 2
+ #endif
#ifndef i_keyfrom
#define i_keyfrom c_default_from
#endif
@@ -250,5 +255,6 @@ #undef _i_prefix
#undef _i_no_clone
#undef _i_no_emplace
+#undef _i_no_hash
#undef _i_template
#endif
|
