{"id":20191402,"url":"https://github.com/htfy96/policycb","last_synced_at":"2026-05-11T00:41:28.497Z","repository":{"id":223401668,"uuid":"760171489","full_name":"htfy96/PolicyCB","owner":"htfy96","description":"Policy-based C++ Callback implementation","archived":false,"fork":false,"pushed_at":"2024-02-20T01:08:43.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T18:52:21.562Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htfy96.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":"2024-02-19T23:10:01.000Z","updated_at":"2024-02-22T07:11:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2c7cb71-953e-4dbd-b4c8-6efaf13a9c1d","html_url":"https://github.com/htfy96/PolicyCB","commit_stats":null,"previous_names":["htfy96/policycb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2FPolicyCB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2FPolicyCB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2FPolicyCB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htfy96%2FPolicyCB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htfy96","download_url":"https://codeload.github.com/htfy96/PolicyCB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241629736,"owners_count":19993707,"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-11-14T03:48:45.182Z","updated_at":"2026-05-11T00:41:23.469Z","avatar_url":"https://github.com/htfy96.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PolicyCB\n\nPolicyCB is a C++20 library that provides a flexbible Callback implementation. This is a highly experimental implementation and shouldn't be use in any production environment. View the associated [Blog post](https://intmainreturn0.com/notes/callback-design.html) for more details. Users may configure the behavior of the class via the below template parameters:\n\n```cpp\n// The policy on allowed callable and Callback itself\n// Note that when none of them is DYNAMIC, Callback\u003c\u003e could\n// utilize flattened function pointer to save a virtual call\n// @{\nenum class MovePolicy\n{\n    // Allows non-trivially movable object\n    DYNAMIC = 0,\n    // Only allows trivially movable object\n    TRIVIAL_ONLY = 1,\n    // Forbids any move on Callback\n    NOMOVE = 2,\n};\n\nenum class CopyPolicy\n{\n    // Allows non-trivially copyable object\n    DYNAMIC = 0,\n    // Only allows trivially copyable object\n    TRIVIAL_ONLY = 1,\n    // Forbids any copy on Callback\n    NOCOPY = 2,\n};\n\nenum class DestroyPolicy\n{\n    // Allows non-trivially destructable object\n    DYNAMIC = 0,\n    // Only allows trivially destructable object\n    TRIVIAL_ONLY = 1,\n};\n\n// @}\n\n// Policy on the small-buffer-optimization storage\nenum class SBOPolicy\n{\n    // Allows the Callback to store arbitrary-sized object\n    // The storage takes InitialBufferSize + 8 bytes\n    DYNAMIC_GROWTH = 0,\n    // Only allows the Callback to store a object with specified\n    // maximum size. Causes an compilation error if the object is\n    // too large.\n    FIXED_SIZE = 1,\n    // This disables storage of the original function,\n    // essentially makes the Callback a function pointer\n    NO_STORAGE = 2,\n};\n\n\ntemplate\u003ctypename FT, // function signature\n         MovePolicy MP,\n         CopyPolicy CP,\n         DestroyPolicy DP,\n         SBOPolicy SBOP,\n         std::size_t InitialBufferSize = 16\u003e\nclass Callback;\n```\n\nThis is a header-only library. Drop in `include/PolicyCB.hpp` into your project to use it.\n\n## License\n\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtfy96%2Fpolicycb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtfy96%2Fpolicycb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtfy96%2Fpolicycb/lists"}