{"id":21325636,"url":"https://github.com/andreysolovyev381/zip_in_cpp","last_synced_at":"2026-02-19T14:06:46.438Z","repository":{"id":147999939,"uuid":"607923372","full_name":"andreysolovyev381/zip_in_cpp","owner":"andreysolovyev381","description":"REAL zip iterator, that will be considered as an Iterator by other C++ code.","archived":false,"fork":false,"pushed_at":"2025-04-14T14:07:03.000Z","size":113,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T07:31:56.856Z","etag":null,"topics":["concepts","cplusplus","cpp","cpp17","cpp20","header-only","header-only-library","headeronly","iter","iterator","metaprogramming","zip"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreysolovyev381.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-01T00:16:40.000Z","updated_at":"2025-04-14T14:07:07.000Z","dependencies_parsed_at":"2025-06-02T19:53:49.730Z","dependency_job_id":null,"html_url":"https://github.com/andreysolovyev381/zip_in_cpp","commit_stats":null,"previous_names":["andreysolovyev381/zip_in_cpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andreysolovyev381/zip_in_cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreysolovyev381%2Fzip_in_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreysolovyev381%2Fzip_in_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreysolovyev381%2Fzip_in_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreysolovyev381%2Fzip_in_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreysolovyev381","download_url":"https://codeload.github.com/andreysolovyev381/zip_in_cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreysolovyev381%2Fzip_in_cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29616961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concepts","cplusplus","cpp","cpp17","cpp20","header-only","header-only-library","headeronly","iter","iterator","metaprogramming","zip"],"created_at":"2024-11-21T21:06:49.449Z","updated_at":"2026-02-19T14:06:46.419Z","avatar_url":"https://github.com/andreysolovyev381.png","language":"C++","readme":"## Zip in C++\n### Reasoning and Some info\nI like small useful snippets, like this one. Let myself have an entertaining night while coding this exercise.\n- Standard and Compilers: works like a charm in 17 and 20 (in case you are not yet in 23, but when you are there, you should take a look at [respective page at cppref](https://en.cppreference.com/w/cpp/ranges/zip_view)). Anyway, this impl compiles ok by gcc and clang on Linux - see GH Actions for this repo. Dependencies: header only, STL only.\n- Iterator's big five is properly defined in the class: value_type, reference, difference_type, pointer, iterator_category. So other C++ code will consider this zip_iterator as an iterator as well.\n- Lots of concept (C++20) and SFINAE (C++17) guards will fail the attempts of enlightened user to get an iterator from type void. Compile with WRONG_ITERATOR_COMPILE_FAILURE to see compile-time errors generated by the tests, or simply uncomment this #define in the test file.\n- UI is simple - call 'zip' using either arbitrary number of containers or arbitrary number of iterators as the arguments. **If there are containers, then 'zip' provides A PAIR of iterators for each container, begin() and end() respectively.**\n- It is tested - see the file.\n- Problems - move_iterators work by copying r_value_references :see_no_evil: Maybe will fix it later :nerd_face:\n\n### Usage\nPretty much straightforward, see the test file. Here is the most vivid example:\n```c++\n\tstd::vector\u003cint\u003e v{ 1,2,3,4,5 };\n\tstd::map\u003cint, std::string\u003e m { {1, \"one\"s}, {2, \"two\"s}, {3, \"three\"s}, };\n\tstd::string s { \"abcdefghhlk\" };\n\t\n\t/// Here it is, see the for loop expr\n\tfor (auto const\u0026 [i, pair, ch] : itertools::zip(v, m, s)) {\n\t\tstd::cout \u003c\u003c i \u003c\u003c ' ' \u003c\u003c pair.first \u003c\u003c ' ' \u003c\u003c pair.second \u003c\u003c ' ' \u003c\u003c ch \u003c\u003c '\\n';\n\t}\n```\n\nAnother example, if zipping iterators instead of containers:\n\n```c++\n\tstruct TestStruct {\n\t\tstd::map\u003cint, std::string\u003e m { {1, \"one\"s}, {2, \"two\"s}, {3, \"three\"s}, };\n\t\tauto begin() const { return m.begin(); }\n\t\tauto end() const { return m.end(); }\n\t};\n\tTestStruct test_struct;\n\tstd::vector\u003cint\u003e v{ 1,2,3,4,5 };\n\tstd::string s { \"abcdefghlk\" };\n\n\t/// Here it is, zipping different input iterators - normal, constant and reverse\n\tauto begin = itertools::zip(v.cbegin(), s.crbegin(), test_struct.begin());\n\tauto end = itertools::zip(v.cend(), s.crend(), test_struct.end());\n\n\tfor (auto itb = begin; itb != end; ++itb ) {\n\t\tauto const \u0026[normal, const_reverse, const_normal] = itb;\n\t\tauto const \u0026[i, c] = const_normal;\n\t\tstd::cout \u003c\u003c normal \u003c\u003c ' ' \u003c\u003c const_reverse \u003c\u003c ' ' \u003c\u003c i \u003c\u003c ' ' \u003c\u003c c \u003c\u003c '\\n';\n\t}\n\n```\n\n### Disclaimer \nFeel free to use it for your needs at your own risk. No guarantees of any kind is given :)\n\n### License\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreysolovyev381%2Fzip_in_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreysolovyev381%2Fzip_in_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreysolovyev381%2Fzip_in_cpp/lists"}