{"id":16690733,"url":"https://github.com/nixman/overloaded","last_synced_at":"2025-10-06T17:21:27.132Z","repository":{"id":65044757,"uuid":"12826960","full_name":"niXman/overloaded","owner":"niXman","description":"C++11 library allows to bind different callable into a single holder without any run-time overhead","archived":false,"fork":false,"pushed_at":"2023-01-01T13:11:02.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T15:59:57.501Z","etag":null,"topics":["cpp","overloaded-functions"],"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/niXman.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}},"created_at":"2013-09-14T09:15:09.000Z","updated_at":"2023-01-01T12:20:40.000Z","dependencies_parsed_at":"2023-01-31T22:30:23.705Z","dependency_job_id":null,"html_url":"https://github.com/niXman/overloaded","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Foverloaded","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Foverloaded/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Foverloaded/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niXman%2Foverloaded/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niXman","download_url":"https://codeload.github.com/niXman/overloaded/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475330,"owners_count":20296714,"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":["cpp","overloaded-functions"],"created_at":"2024-10-12T16:05:09.303Z","updated_at":"2025-10-06T17:21:22.052Z","avatar_url":"https://github.com/niXman.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Overloaded\n=========\n\nThis C++11 library allows to bind different `callable` into a single holder without any run-time overhead.\n\nExample\n=========\n```cpp\nint add(int a, int b) { return a+b; }\ndouble mul(double a, double b){ return a*b; }\n\nauto func = overloaded::make(add, mul);\n\nstd::assert(func(2, 2) == 4);\nstd::assert(func(2.2, 2.2) == 4.84);\n```\n\nOverhead\n=========\nFor the following example:\n```cpp\n/***************************************************************************/\n\n__attribute__ ((noinline))\nint f2(const int \u0026v) {return v*2;}\n\n__attribute__ ((noinline))\nint f3(int \u0026v) {v = v*2; return v;}\n\n/***************************************************************************/\n\nint main(int argc, char **) {\n    int res = 0;\n    auto *fp = \u0026f2;\n    auto overloaded = overloaded::make(fp, f3);\n    res += overloaded(argc); // f3()\n    res += overloaded(static_cast\u003cconst int \u0026\u003e(argc)); // f2()\n\n    return res;\n}\n\n/***************************************************************************/\n```\nthe following ASM will be generated:\n```asm\nf2(int const\u0026):\n        mov     eax, DWORD PTR [rdi]\n        add     eax, eax\n        ret\nf3(int\u0026):\n        mov     eax, DWORD PTR [rdi]\n        add     eax, eax\n        mov     DWORD PTR [rdi], eax\n        ret\nmain:\n        sub     rsp, 8\n        mov     DWORD PTR [rsp+4], edi\n        lea     rdi, [rsp+4]\n        call    f2(int const\u0026)\n        mov     edx, eax\n        call    f3(int\u0026)\n        add     rsp, 8\n        add     eax, edx\n        ret\n```\nAs you can see, there is nothing superfluous here!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixman%2Foverloaded","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnixman%2Foverloaded","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixman%2Foverloaded/lists"}