summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-10-04 09:07:51 +0200
committerTyge Løvset <[email protected]>2021-10-04 09:07:51 +0200
commit35997591de5a448752734c822b0f1003e08853a5 (patch)
treee6252c64b71014feb10f3338f663d6d1ea7dfa3b
parentd314fa40bcfc3a7d5e4dfc8136aebff309db8667 (diff)
downloadSTC-modified-35997591de5a448752734c822b0f1003e08853a5.tar.gz
STC-modified-35997591de5a448752734c822b0f1003e08853a5.zip
Fixed a small bug and simplified template.h
-rw-r--r--docs/ccommon_api.md4
-rw-r--r--include/stc/template.h30
2 files changed, 14 insertions, 20 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 5f31e572..902b33f5 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -122,16 +122,14 @@ c_forrange (i, int, 30, 0, -5) printf(" %d", i);
// 30 25 20 15 10 5
```
-### c_apply, c_apply_pair
+### c_apply, c_apply_pair, c_apply_n
**c_apply** will apply a method on an existing container with the given array elements:
```c
c_apply(cvec_i, push_back, &vec, {1, 2, 3}); // apply multiple push_backs
c_apply_pair(cmap_i, insert, &map, { {4, 5}, {6, 7} }); // inserts to existing map
int arr[] = {1, 2, 3};
-cmap_i_value_t arr2[] = { {4, 5}, {6, 7} };
c_apply_n(cvec_i, push_back, &vec, arr, c_arraylen(arr));
-c_apply_pair_n(cmap_i, insert, &map, arr2, c_arraylen(arr2));
```
### c_new, c_new_n, c_del, c_make
diff --git a/include/stc/template.h b/include/stc/template.h
index cecf9790..865e5b83 100644
--- a/include/stc/template.h
+++ b/include/stc/template.h
@@ -54,30 +54,16 @@
#endif
#ifdef i_key_csptr
- #ifndef i_tag
- #define i_tag i_key_csptr
- #endif
#define i_key i_key_csptr
#define i_cmp c_PASTE(i_key_csptr, _compare)
#define i_keydel c_PASTE(i_key_csptr, _del)
#define i_keyfrom c_PASTE(i_key_csptr, _clone)
#endif
-#ifdef i_val_csptr
- #if !defined i_tag && !defined i_key
- #define i_tag i_val_csptr
- #endif
- #define i_val i_val_csptr
- #ifndef i_key
- #define i_cmp c_PASTE(i_val_csptr, _compare)
- #endif
- #define i_valdel c_PASTE(i_val_csptr, _del)
- #define i_valfrom c_PASTE(i_val_csptr, _clone)
-#endif
#ifdef i_key_str
#define i_key cstr
#ifndef i_tag
- #define i_tag str
+ #define i_tag str
#endif
#define i_cmp c_rawstr_compare
#define i_hash c_rawstr_hash
@@ -86,13 +72,23 @@
#define i_keyto cstr_str
#define i_keyraw const char*
#endif
+
+#ifdef i_val_csptr
+ #define i_val i_val_csptr
+ #ifndef i_key
+ #define i_cmp c_PASTE(i_val_csptr, _compare)
+ #endif
+ #define i_valdel c_PASTE(i_val_csptr, _del)
+ #define i_valfrom c_PASTE(i_val_csptr, _clone)
+#endif
+
#ifdef i_val_str
#define i_val cstr
#if !defined i_tag && !defined i_key
- #define i_tag str
+ #define i_tag str
#endif
#ifndef i_key
- #define i_cmp c_rawstr_compare
+ #define i_cmp c_rawstr_compare
#endif
#define i_valdel cstr_del
#define i_valfrom cstr_from