{"id":19534859,"url":"https://github.com/newyaroslav/unique_class_id","last_synced_at":"2025-10-08T21:16:07.645Z","repository":{"id":162735418,"uuid":"600647315","full_name":"NewYaroslav/unique_class_id","owner":"NewYaroslav","description":"unique_class_id is a header-only C++ library that allows giving classes a unique ID and then comparing classes based on their unique IDs.","archived":false,"fork":false,"pushed_at":"2024-05-14T03:51:21.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-26T20:12:58.961Z","etag":null,"topics":["class-identifier","cpp","cpp11","guid","header-only","unique-id","unique-identifier"],"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/NewYaroslav.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-02-12T06:03:44.000Z","updated_at":"2024-05-14T03:51:24.000Z","dependencies_parsed_at":"2024-04-07T01:45:55.304Z","dependency_job_id":"8ce339a5-cc69-477d-ac52-2940cabb73b4","html_url":"https://github.com/NewYaroslav/unique_class_id","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NewYaroslav/unique_class_id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewYaroslav%2Funique_class_id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewYaroslav%2Funique_class_id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewYaroslav%2Funique_class_id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewYaroslav%2Funique_class_id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NewYaroslav","download_url":"https://codeload.github.com/NewYaroslav/unique_class_id/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewYaroslav%2Funique_class_id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000718,"owners_count":26082837,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["class-identifier","cpp","cpp11","guid","header-only","unique-id","unique-identifier"],"created_at":"2024-11-11T02:16:21.066Z","updated_at":"2025-10-08T21:16:07.574Z","avatar_url":"https://github.com/NewYaroslav.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unique_class_id\nunique_class_id is a header-only C++ library that allows giving classes a unique ID and then comparing classes based on their unique IDs.\n\n## Description\nUnique class id library is a header-only library that allows classes to have unique IDs and then compare classes based on their unique IDs.\n\nTo use the library, simply include the header \"unique_class_id.hpp\" in your code.\n\nAn example of using the library is shown below:\n\n```cpp\n#include \u003ciostream\u003e\n#include \"unique_class_id.hpp\"\n\nclass A {\n    DEFINE_UNIQUE_CLASS_ID(A)\n};\n\nclass B : public A {\n    DEFINE_UNIQUE_CLASS_ID(B)\n};\n\nclass Base {\npublic:\n    virtual unique_class_id::class_id_t id() const = 0;\n};\n\nclass DerivedA : public Base {\n    DEFINE_FINAL_UNIQUE_CLASS_ID(DerivedA)\n};\n\nclass DerivedB : public Base {\n    DEFINE_FINAL_UNIQUE_CLASS_ID(DerivedB)\n};\n\nint main() {\n    A *a = new A();\n    B *b = new B();\n\n    if (unique_class_id::is_same_class\u003cA\u003e(b)) {\n        std::cout \u003c\u003c \"Same class\" \u003c\u003c std::endl;\n    } else {\n        std::cout \u003c\u003c \"Different class\" \u003c\u003c std::endl;\n    }\n\n    Base *base_ptr = new DerivedA();\n    unique_class_id::class_id_t base_id = base_ptr-\u003eid();\n    unique_class_id::class_id_t derived_a_id = DerivedA().id();\n    unique_class_id::class_id_t derived_b_id = DerivedB().id();\n    if (base_id == derived_a_id) {\n        std::cout \u003c\u003c \"Base pointer is pointing to DerivedA\\n\";\n    } else \n    if (base_id == derived_b_id) {\n        std::cout \u003c\u003c \"Base pointer is pointing to DerivedB\\n\";\n    }\n\n\tdelete a;\n\tdelete b;\n\tdelete base_ptr;\n    return 0;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewyaroslav%2Funique_class_id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewyaroslav%2Funique_class_id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewyaroslav%2Funique_class_id/lists"}