-
Notifications
You must be signed in to change notification settings - Fork 1
"for each" constructs for C++11 that provide iteration over multiple containers at the same time (zipping, or parallel iteration -- not parallel computation)
License
cshelton/zipfor
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
zipfor
======
for-each constructs for C++11 that provide iteration over multiple
containers at the same time (zipping, or parallel iteration -- not
parallel computation)
primarily provides zipfor:
--------------------------
can be used as
vector<int> a {1,2,3};
array<string,3> b {"hello","there","coders"};
zipfor(i,s eachin a,b)
cout << i << " => " << s;
also provides mapfor:
---------------------
map<int,string> m{{1,"hello"},{2,"there"},{-3,"stranger"}};
mapfor(i,s eachin m)
cout << i << " => " << s;
finally, provides ittcounter<T>:
--------------------------------
This is a simple container that counter from 0, by 1s
ittcounter<int>() or ittcounter<float>() or ittcounter<size_t>()
icounter is the same as ittcounter<int>()
can be used like:
map<char,string> m{{'a',"apple"},{'b',"ball"},{'c',"chair"}};
zipfor(v,i eachin m,icounter)
cout << i << ": " << v.first << " => " << v.second << endl;
icounter (or ittcounter) should *not* be the first member in list
(or the loop will run for a very long time)
Notes:
-----
o This is a header-only "library" so no compilation is necessary.
o It depends heavily on C++11 (it will not work with C++03 or earlier)
o It has been tested on g++4.8.1 but nothing else at this point (Jun 2014)
o It was briefly tested on g++9.3.1 to fix a bug (Apr 2020)
o It *does* use macros to provide the syntax sugar.
o Any bug reports would be appreciated.
-Christian
About
"for each" constructs for C++11 that provide iteration over multiple containers at the same time (zipping, or parallel iteration -- not parallel computation)
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published