{"id":18447032,"url":"https://github.com/zhb2000/pointer-declaration","last_synced_at":"2025-04-15T02:45:46.870Z","repository":{"id":108880713,"uuid":"335512791","full_name":"zhb2000/Pointer-Declaration","owner":"zhb2000","description":"Declare all kinds of pointers with Ptr\u003c...\u003e","archived":false,"fork":false,"pushed_at":"2021-02-03T05:13:15.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T02:45:42.474Z","etag":null,"topics":["c-plus-plus","cpp"],"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/zhb2000.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":"2021-02-03T05:02:44.000Z","updated_at":"2021-02-03T05:13:17.000Z","dependencies_parsed_at":"2023-03-27T08:13:35.951Z","dependency_job_id":null,"html_url":"https://github.com/zhb2000/Pointer-Declaration","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/zhb2000%2FPointer-Declaration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhb2000%2FPointer-Declaration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhb2000%2FPointer-Declaration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhb2000%2FPointer-Declaration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhb2000","download_url":"https://codeload.github.com/zhb2000/Pointer-Declaration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997087,"owners_count":21195797,"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":["c-plus-plus","cpp"],"created_at":"2024-11-06T07:11:48.589Z","updated_at":"2025-04-15T02:45:46.853Z","avatar_url":"https://github.com/zhb2000.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pointer Declaration\nA header-only C++11 \"library\" providing an alias template `ptrdecl::Ptr` for pointer declarations.\n\n## Features\n\n- Use angle brackets instead of star symbols\n- Declare all kinds of pointers with uniform syntax\n- Clearer sematic, especially when it comes to multi-level pointers and pointers with cv-qualifiers\n\n## How to use\n```cpp\n#include \"ptrdecl.hpp\"\nusing ptrdecl::Ptr;\n```\n\n### Pointers to objects\nDeclare pointers to objects with `Ptr\u003cT\u003e`.\n\n```cpp\n// int *p1;\nPtr\u003cint\u003e p1;\n\n// void *p2;\nPtr\u003cvoid\u003e p2;\n\n// const int *p3;\n// int const *p3;\nPtr\u003cconst int\u003e p3;\n\n// int *const p4 = nullptr;\nconst Ptr\u003cint\u003e p4 = nullptr;\n\n// const int *const p5 = nullptr;\n// int const *const p5 = nullptr;\nconst Ptr\u003cconst int\u003e p5 = nullptr;\n\n// int *const *p6;\nPtr\u003cconst Ptr\u003cint\u003e\u003e p6;\n\n//const int **const p7 = nullptr;\nconst Ptr\u003cPtr\u003cconst int\u003e\u003e p7 = nullptr;\n\n//int *const *const p8 = nullptr;\nconst Ptr\u003cconst Ptr\u003cint\u003e\u003e p8 = nullptr;\n```\n\n### Pointers to functions\nDeclare pointers to functions with `Ptr\u003cSignature\u003e`.\n\n```cpp\n// int (*p1)(int, int);\nPtr\u003cint(int, int)\u003e p1;\n\n// void (*p2)();\nPtr\u003cvoid()\u003e p2;\n\n// int *(*p3)();\nPtr\u003cPtr\u003cint\u003e()\u003e p3;\n\n// int (*(*p4)())();\nPtr\u003cPtr\u003cint()\u003e()\u003e p4;\n\n// int *(*callbacks[5])();\nPtr\u003cPtr\u003cint\u003e()\u003e callbacks[5];\n```\n\n### Pointers to data members\nDeclare pointers to data members with `Ptr\u003cClass, T\u003e`.\n\n```cpp\nstruct C { int m; };\n\n// int C::*p = \u0026C::m;\nPtr\u003cC, int\u003e p = \u0026C::m;\n```\n\n### Pointers to member functions\nDeclare pointers to member functions with `Ptr\u003cClass, Signature\u003e`.\n\n```cpp\nstruct C\n{\n    int f(int a) { return a + 1; }\n};\n\n// int (C::*p)(int) = \u0026C::f;\nPtr\u003cC, int(int)\u003e p = \u0026C::f;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhb2000%2Fpointer-declaration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhb2000%2Fpointer-declaration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhb2000%2Fpointer-declaration/lists"}