{"id":26059638,"url":"https://github.com/mnikander/cpp_bind","last_synced_at":"2025-07-04T03:06:48.829Z","repository":{"id":244251330,"uuid":"814698708","full_name":"mnikander/cpp_bind","owner":"mnikander","description":"Prototype for a concise argument binding syntax to replace lambda expressions in some contexts","archived":false,"fork":false,"pushed_at":"2025-05-12T10:03:38.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T11:25:01.139Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mnikander.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":"2024-06-13T14:17:39.000Z","updated_at":"2025-05-12T10:03:41.000Z","dependencies_parsed_at":"2024-06-13T17:28:36.532Z","dependency_job_id":"ed9d50e0-ee6a-4a5e-9675-86726b15081f","html_url":"https://github.com/mnikander/cpp_bind","commit_stats":null,"previous_names":["manik7/cpp_argument_binding","mnikander/cpp_bind"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mnikander/cpp_bind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Fcpp_bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Fcpp_bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Fcpp_bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Fcpp_bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnikander","download_url":"https://codeload.github.com/mnikander/cpp_bind/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Fcpp_bind/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263437345,"owners_count":23466368,"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":[],"created_at":"2025-03-08T13:26:51.547Z","updated_at":"2025-07-04T03:06:48.800Z","avatar_url":"https://github.com/mnikander.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Argument binding\n\nPrototype a concise syntax for argument binding, using operator overloading.\n\n## Getting started\n\n1. Install dependencies\n```bash\nsudo apt get install libgtest-dev cmake g++\n```\n\n2. Clone the repo\n```bash\ngit clone #...\n```\n\n3. Build and run:\n```bash\n# out-of-source build\ncd cpp_bind \u0026\u0026 mkdir out \u0026\u0026 cd out \u0026\u0026 cmake .. \u0026\u0026 cd ..\ncmake --build out/ \u0026\u0026 ./out/unit_tests\n```\n\n## Simple example\n\nCreate function objects where one argument of a binary function has been bound:\n\n```cpp\n    auto twoMinus = 2 \u003e\u003e= std::minus\u003c\u003e{};  // bind left argument to 2\n    auto minusTwo = std::minus\u003c\u003e{} \u003c\u003c= 2;  // bind right argument to 2\n```\n\n## Usage example: subtract one from each element\n\nGiven:\n```cpp\nconst std::vector\u003cint\u003e v{1, 2, 4, 8};\nstd::vector\u003cint\u003e result(v.size());\n```\n\nThis is how we would normally subtract one from each element in a sequence:\n```cpp\nstd::transform(v.cbegin(),\n               v.cend(),\n               0,\n               [](int i){ return i-1; });\n```\n\nWith the argument binding enabled, we can instead write it like this:\n```cpp\nusing namespace bind; // make the overloads for operator\u003e\u003e= and operator\u003c\u003c= available\n\nstd::transform(v.cbegin(),\n               v.cend(),\n               0,\n               std::minus\u003c\u003e{} \u003c\u003c= 1); // bind right argument of 'minus' to equal 1\n```\n\nFor binary functions which have their own operator symbol, such as + - * / ect, a lambda expression is shorter, but for\nfunction-like objects without its own special symbol, the overload syntax is shorter and simpler.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnikander%2Fcpp_bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnikander%2Fcpp_bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnikander%2Fcpp_bind/lists"}