nrr_enumerate:C ++的类似Python的“枚举”

时间:2021-05-09 18:53:51
【文件属性】:
文件名称:nrr_enumerate:C ++的类似Python的“枚举”
文件大小:7KB
文件格式:ZIP
更新时间:2021-05-09 18:53:51
C++ nrr_enumerate C ++的类似Python的“枚举” Python和其他一些语言有一个方便的内置函数,称为 ,它使您可以迭代对象(例如列表),并且可以在每次迭代中访问索引和项目。 此标头提供了相同想法的C ++ 17/20实现。 像这样使用它: std::vector things; ... for ( auto [i, thing] : enumerate(things)) { // i gets the index and thing gets the Thing in each iteration } 在things本身上进行迭代会给您带来thing ,但不会给i ,并且在很多情况下您都希望两者兼具。 有关更多信息,请参见。 还有一个const版本cenumerate() ,它将给定的对象迭代为const。 (遗憾的是,由于某些原因,使用c
【文件预览】:
nrr_enumerate-main
----include()
--------nrr_enumerate()
----.gitignore(18B)
----CMakeLists.txt(754B)
----README.md(973B)
----.editorconfig(133B)
----.gitattributes(70B)
----LICENSE.txt(11KB)

网友评论