代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。