diff options
| author | Tyge Løvset <[email protected]> | 2022-10-07 22:19:36 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-10-07 22:19:36 +0200 |
| commit | 5fb5ed08250b5ad4eadd6e7a9fdc44f4519b15ff (patch) | |
| tree | 8fd0bfb5e9f7f062aec7a31ef32aa29a245ab1fc /include/stc | |
| parent | 0bb5902e347c6b503c80ba6d6e74dc880b1bc736 (diff) | |
| parent | 12d854b17371903253cd54e8cbb1a947b637de83 (diff) | |
| download | STC-modified-5fb5ed08250b5ad4eadd6e7a9fdc44f4519b15ff.tar.gz STC-modified-5fb5ed08250b5ad4eadd6e7a9fdc44f4519b15ff.zip | |
Merge branch 'master' of github.com:tylov/STC
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/ccommon.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 0e5b3b22..e3406727 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -238,13 +238,13 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, #define c_drop(C, ...) do { c_forlist (_i, C*, {__VA_ARGS__}) C##_drop(*_i.ref); } while(0) -#define c_find_if(it, C, cnt, pred) do { \ +#define c_find_if(...) c_MACRO_OVERLOAD(c_find_if, __VA_ARGS__) +#define c_find_if4(it, C, cnt, pred) do { \ size_t index = 0; \ for (it = C##_begin(&cnt); it.ref && !(pred); C##_next(&it)) \ ++index; \ } while (0) - -#define c_find_in(it, C, start, end, pred) do { \ +#define c_find_if5(it, C, start, end, pred) do { \ size_t index = 0; \ const C##_value* _endref = (end).ref; \ for (it = start; it.ref != _endref && !(pred); C##_next(&it)) \ @@ -253,12 +253,10 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, } while (0) #define c_erase_if(it, C, cnt, pred) do { \ - size_t index = 0, count = 0; \ C##_iter it = C##_begin(&cnt); \ - while (it.ref) { \ - if (pred) it = C##_erase_at(&cnt, it), ++count; \ + for (size_t index = 0; it.ref; ++index) { \ + if (pred) it = C##_erase_at(&cnt, it); \ else C##_next(&it); \ - ++index; \ } \ } while (0) |
