{"id":19157775,"url":"https://github.com/coyorkdow/deco_cpp","last_synced_at":"2026-04-19T01:01:48.374Z","repository":{"id":174261977,"uuid":"651994903","full_name":"coyorkdow/deco_cpp","owner":"coyorkdow","description":"Python style decorator in C++","archived":false,"fork":false,"pushed_at":"2023-06-10T18:46:57.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T20:28:11.950Z","etag":null,"topics":["cpp","cpp17","decorator","metaprogramming","python"],"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/coyorkdow.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}},"created_at":"2023-06-10T18:32:13.000Z","updated_at":"2024-05-20T10:12:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"f664b326-459a-45f8-b4cf-4b7bec4399b5","html_url":"https://github.com/coyorkdow/deco_cpp","commit_stats":null,"previous_names":["coyorkdow/deco_cpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coyorkdow%2Fdeco_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coyorkdow%2Fdeco_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coyorkdow%2Fdeco_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coyorkdow%2Fdeco_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coyorkdow","download_url":"https://codeload.github.com/coyorkdow/deco_cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240241820,"owners_count":19770466,"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","cpp17","decorator","metaprogramming","python"],"created_at":"2024-11-09T08:42:03.606Z","updated_at":"2026-04-19T01:01:46.149Z","avatar_url":"https://github.com/coyorkdow.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deco_cpp\nPython style decorator in C++\n\nIn Python, you can easily use the decorator to enhance a function, like\n```python\nimport functools\n\n@functools.cache\ndef fibonacci(a):\n    if a == 1:\n        return 0\n    elif a == 2:\n        return 1\n    else:\n        return fibonacci(a - 2) + fibonacci(a - 1)\n    \nfor i in range(1, 50):\n    print(fibonacci(i), end=' ')\n```\n`deco_cpp` allows you to use the similar syntax in cpp.\nc++17 required.\n\n# Example\n\nThis example shows how to write a recursive fibonacci sequence function, with a memorization decorator. Note the `auto` in function parameter is a c++20 feature. If you use c++17, please change to the `template\u003ctypename T\u003e uint64_t Call(T\u0026 self, uint32_t a)`.\n```c++\n#include \"decorator.hpp\"\n\nstruct Fibonacci : deco::Decorate\u003cFibonacci, deco::Memorization\u003e {\n  uint64_t Call(auto\u0026 self, uint32_t a) {\n    if (a == 1) {\n      return 0;\n    } else if (a == 2) {\n      return 1;\n    } else {\n      return self(a - 1) + self(a - 2);\n    }\n  }\n};\n\nint main() {\n  Fibonacci fib;\n  for (int i = 1; i \u003c 50; i++) {\n    std::cout \u003c\u003c fib(i) \u003c\u003c ' ';\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoyorkdow%2Fdeco_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoyorkdow%2Fdeco_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoyorkdow%2Fdeco_cpp/lists"}