{"id":13730554,"url":"https://github.com/pmed/fixed_size_function","last_synced_at":"2025-03-21T18:33:41.735Z","repository":{"id":19611362,"uuid":"22862616","full_name":"pmed/fixed_size_function","owner":"pmed","description":"Fixed size function wrapper like std::function","archived":false,"fork":false,"pushed_at":"2016-05-01T13:46:50.000Z","size":9,"stargazers_count":69,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T04:09:36.041Z","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/pmed.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":"2014-08-12T02:50:29.000Z","updated_at":"2024-12-03T03:56:11.000Z","dependencies_parsed_at":"2022-07-23T13:02:26.781Z","dependency_job_id":null,"html_url":"https://github.com/pmed/fixed_size_function","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/pmed%2Ffixed_size_function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmed%2Ffixed_size_function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmed%2Ffixed_size_function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmed%2Ffixed_size_function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmed","download_url":"https://codeload.github.com/pmed/fixed_size_function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244849797,"owners_count":20520791,"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":"2024-08-03T02:01:16.506Z","updated_at":"2025-03-21T18:33:41.361Z","avatar_url":"https://github.com/pmed.png","language":"C++","readme":"Fixed size function\n===================\n\nFixed size function wrapper like [std::function](http://en.cppreference.com/w/cpp/utility/functional/function) to avoid dynamic memory allocation.\n\nUsage:\n\n```c++\n#include \"fixed_size_function.hpp\"\n\nint f(int a)\n{\n\tstd::cout \u003c\u003c __FUNCTION__ \u003c\u003c \"\\n\";\n\treturn a; \n}\n\nint g(int a, int b)\n{\n\tstd::cout \u003c\u003c __FUNCTION__ \u003c\u003c \"\\n\";\n\treturn a;\n}\n\nstruct X\n{\n\tint operator()(int a) const\n\t{\n\t\tstd::cout \u003c\u003c __FUNCTION__ \u003c\u003c \"\\n\";\n\t\treturn a;\n\t}\n\n\tint mem_fun(int a)\n\t{\n\t\tstd::cout \u003c\u003c __FUNCTION__ \u003c\u003c \"\\n\";\n\t\treturn a;\n\t}\n};\n\nint main()\n{\n\tfixed_size_function\u003cint(int), 256\u003e fun;\n\n\t// Functor\n\tX x;\n\tfun = x;\n\tfun(1);\n\n\t// Free function\n\tfun = f;\n\tfun(2);\n\n\t// Bind function\n\tfun = std::bind(g, std::placeholders::_1, 0);\n\tfun(3);\n\n\t// Bind member function\n\tfun = std::bind(\u0026X::mem_fun, x, std::placeholders::_1);\n\tfun(4);\n\n\t// Lambda\n\tfun = [](int a) -\u003e int\n\t{\n\t\tstd::cout \u003c\u003c __FUNCTION__ \u003c\u003c \"\\n\";\n\t\treturn a;\n\t};\n\tfun(5);\n\n}\n```\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmed%2Ffixed_size_function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmed%2Ffixed_size_function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmed%2Ffixed_size_function/lists"}