{"id":19035284,"url":"https://github.com/tradias/lambda-tuple","last_synced_at":"2025-10-18T12:59:56.741Z","repository":{"id":52340534,"uuid":"520907701","full_name":"Tradias/lambda-tuple","owner":"Tradias","description":"An implementation of `std::tuple` based on variadic lambda capture","archived":false,"fork":false,"pushed_at":"2024-09-16T18:13:22.000Z","size":73,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T09:03:56.438Z","etag":null,"topics":["compile-time","cpp","cpp20","header-only","lambda","tuple"],"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/Tradias.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-08-03T14:11:13.000Z","updated_at":"2024-09-16T18:02:49.000Z","dependencies_parsed_at":"2025-04-17T14:58:08.273Z","dependency_job_id":"e598ef36-1b9d-424f-99fd-a91e592a9148","html_url":"https://github.com/Tradias/lambda-tuple","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Tradias/lambda-tuple","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tradias%2Flambda-tuple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tradias%2Flambda-tuple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tradias%2Flambda-tuple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tradias%2Flambda-tuple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tradias","download_url":"https://codeload.github.com/Tradias/lambda-tuple/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tradias%2Flambda-tuple/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263245254,"owners_count":23436511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["compile-time","cpp","cpp20","header-only","lambda","tuple"],"created_at":"2024-11-08T21:49:59.962Z","updated_at":"2025-10-18T12:59:51.717Z","avatar_url":"https://github.com/Tradias.png","language":"C++","readme":"# lambda-tuple\n\nAn implementation of `std::tuple` based on variadic lambda capture ([P0780R2](https://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0780r2.html)) added in C++20. \nThe idea is to store all elements of the tuple in such a lambda:\n\n```cpp\n[... v = std::move(v)](auto f) mutable -\u003e decltype(auto)\n{\n    return f(v...);\n}\n```\n\nI would consider it more of a toy implementation. Nonetheless, there is an extensive test suite including several tests from the Microsoft STL amounting to 75+ tests in total.\n\nPlay with it on [godbolt](https://godbolt.org/z/ajxavsrnM).\n\n## Advantages\n\n* Triviallity of copy/move construction of types is preserved.\n* No template or function recursion used in the implementation.\n* Automatic pretty-printing in the debugger. E.g. for `tuple\u003cint, double\u003e`   \n![Lambda-tuple pretty-print](doc/pretty-print.png \"pretty-printing\")\n* An empty tuple is `std::is_trivial_v`.\n* Roughly 2.6 times faster to compile with GCC and 2 times faster with Clang. ([build-bench](https://build-bench.com/b/OOEJlYo9mQObmYHxBtS8G6-cmAc))\n\n## Disadvantages\n\n* Cannot be passed across DLL boundaries.\n* No in-place construction, just like `std::tuple`.\n* Triviallity of copy/move assignment of types is not preserved, just like `std::tuple`.\n* The compiler is allowed to re-order elements captured in the lambda to minimize its size (by ordering elements by their `sizeof` or performing empty-class optimization). In practice, however, none of the major compilers seem to make use of it. ([godbolt](https://godbolt.org/z/Y5qbMe5Ge))\n\n# Installation\n\nCopy the single header from [src/ltpl/tuple.hpp](src/ltpl/tuple.hpp) into your project.\n\nAlternatively, use CMake to install the project. From the root of the repository:\n\n```cmake\ncmake -B build -S .\ncmake --install build --prefix build/out\n```\n\nAnd in your CMake project's CMakeLists.txt:\n\n```cmake\n# Add build/out to the CMAKE_PREFIX_PATH\nfind_package(lambda-tuple)\ntarget_link_libraries(my_app PRIVATE lambda-tuple::lambda-tuple)\n```\n\n# Usage\n\nInclude the single header:\n\n```cpp\n#include \u003cltpl/tuple.hpp\u003e\n```\n\nAnd use `ltpl::Tuple` just like `std::tuple`.\n\n# Requirements\n\nThe only requirement is a small subset of C++20.\n\nThe following compilers are continuously tested by Github Actions:\n\n* GCC 10,\n* Clang 10\n* MSVc 19.32\n* AppleClang 13\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradias%2Flambda-tuple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftradias%2Flambda-tuple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradias%2Flambda-tuple/lists"}