{"id":18497568,"url":"https://github.com/csb6/strong-types","last_synced_at":"2025-05-14T05:14:16.418Z","repository":{"id":115656502,"uuid":"264759536","full_name":"csb6/strong-types","owner":"csb6","description":"Single-header implementation of strong typedefs in C++","archived":false,"fork":false,"pushed_at":"2020-05-25T20:16:57.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T00:21:09.439Z","etag":null,"topics":["cpp","cpp17","strongly-typed","typedef"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csb6.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":"2020-05-17T21:24:10.000Z","updated_at":"2023-10-11T12:43:33.000Z","dependencies_parsed_at":"2023-05-15T02:45:10.597Z","dependency_job_id":null,"html_url":"https://github.com/csb6/strong-types","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/csb6%2Fstrong-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fstrong-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fstrong-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fstrong-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csb6","download_url":"https://codeload.github.com/csb6/strong-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076851,"owners_count":22010611,"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","strongly-typed","typedef"],"created_at":"2024-11-06T13:34:58.574Z","updated_at":"2025-05-14T05:14:16.392Z","avatar_url":"https://github.com/csb6.png","language":"C++","readme":"# Strong-Types\n\nThis is an extremely simple, single-header implementation of strong typedefs in C++.\nWhile several good strong typedef libraries for C++ exist, most of them\nare complex, making use of a large amount of template metaprogramming to allow levels\nof customization that are not necessary for many cases.\n\nThis library attempts to offer the core functionality of strong typedefs (creating\ntypedef-like types that rename an existing type but are treated as distinct types\nby the compiler) with as little boilerplate as possible. Here is some sample code\ndemonstrating the some of the basic features:\n\n```cpp\n#include \u003ciostream\u003e\n#include \"strong-types.hpp\"\n\nstruct Width : strong_type\u003cunsigned int, Width\u003e {}\nstruct Height : strong_type\u003cunsigned int, Height\u003e {}\n\nint main()\n{\n    Width w{4};\n    Height h{5};\n    h = w; // Compile-time error\n    h += 5;\n    w *= 9;\n    Height h2{6};\n    h = h + h2; // Works\n    std::cout \u003c\u003c h \u003c\u003c std::endl; // Works as expected\n    std::cout \u003c\u003c w \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\n## Features\n\n- Simple creation of typedefs; simply create a struct inheriting from `strong_type\u003cA, B\u003e`,\nwhere `A` is the type you want to typedef and `B` is the type name of the typedef\n- Templated operator overloads, including most arithmetic, comparison, and increment/\ndecrementing operators, as well as an output stream operator. Adding your own operators\nis trivial\n- To access members/member functions of the underlying type, simply access the\n'v' member. If you don't want to see the 'v' member, then simply use private inheritance.\n\nSee `example.cpp` and the files in the `tests` directory for more examples of usage.\n\n[This blog post](https://www.fluentcpp.com/2018/04/06/strong-types-by-struct) by Vincent\nZalzal was the inspiration for this simple method of creating strong typedefs.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsb6%2Fstrong-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsb6%2Fstrong-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsb6%2Fstrong-types/lists"}