{"id":15047436,"url":"https://github.com/tioneb64/cpp-polymorph-class","last_synced_at":"2026-02-01T11:34:30.805Z","repository":{"id":216690500,"uuid":"742056030","full_name":"tioneb64/cpp-polymorph-class","owner":"tioneb64","description":"Two classes to create a polymorphic Array in C++ accepting all types of data","archived":false,"fork":false,"pushed_at":"2024-01-11T17:32:59.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T04:39:51.583Z","etag":null,"topics":["class","code","cpp","cpp14","cpp17","example","polymorphism"],"latest_commit_sha":null,"homepage":"","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/tioneb64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-11T17:10:00.000Z","updated_at":"2024-01-11T17:33:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c6898ba-d8cf-483a-89d4-609e6b4bfc33","html_url":"https://github.com/tioneb64/cpp-polymorph-class","commit_stats":null,"previous_names":["tioneb64/cpp-polymorph-class"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tioneb64/cpp-polymorph-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tioneb64%2Fcpp-polymorph-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tioneb64%2Fcpp-polymorph-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tioneb64%2Fcpp-polymorph-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tioneb64%2Fcpp-polymorph-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tioneb64","download_url":"https://codeload.github.com/tioneb64/cpp-polymorph-class/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tioneb64%2Fcpp-polymorph-class/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28977318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T11:31:13.034Z","status":"ssl_error","status_checked_at":"2026-02-01T11:30:25.558Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","code","cpp","cpp14","cpp17","example","polymorphism"],"created_at":"2024-09-24T20:58:21.331Z","updated_at":"2026-02-01T11:34:30.790Z","avatar_url":"https://github.com/tioneb64.png","language":"C++","readme":"# cpp-polymorph-class\nTwo classes to create a polymorphic Array in C++ accepting all types of data\nI created the small MultiArray project for educational purposes.\n\nIt offers two versions of the same MultiArray class.\n\nThe polymorphic version is flexible but limited. The variant version is limited but flexible.\n\n## Project Explanation:\n\nThe starting premise is that in C++, a multidimensional array is generally a homogeneous structure, meaning that all elements of the array must be of the same data type (int, float, char, std::string, std::vector, ...). However, for a project, I needed to store a certain amount of data with multiple types in an array to work on it easily.\n\nThe MultiArray class is designed to address this issue. It simulates the behavior of an array. A multidimensional array with different data types can be simulated using structures or classes.\n\n## Polymorphic Version:\n\nIn this version, the MultiArrayPolymorphic class uses an internal \"Any\" class that can store any data type using polymorphic pointers. This class is compatible with C++14 to C++20. It is not compatible with C++11 because I use \"std::unique_ptr,\" which did not exist and only appeared in C++14.\n\nThanks to the \"struct Any\" in the class, it can store any data type. The advantage, unlike the \"variant\" version, is that I can add all data types, or almost all. Almost, because unfortunately, I cannot store \u003cvector\u003e in it.\n\nHowever, it has a major advantage over the \"variant\" version; I can add data types without modifying the source. I can compile it into a library without having to recompile it every time I add a new data type.\n\n## Variant Version:\n\nSimilar to the previous version, the MultiArrayVariant class can handle almost all data types. To do this, you just need to add the types that the class container should process in the line:\n\nusing ValueVariant = std::variant\u003cint, float, bool, std::string, std::vector\u003cint\u003e\u003e;\nstd::vector\u003cValueVariant\u003e data;\n\nHowever, if you want to add or remove a type that can be processed by the MultiArrayVariant class, you need to modify this line and then recompile your source.\nThis class is compatible with C++17 to C++20.\n\n\nBoth classes have advantages and disadvantages. Each person will make their choice based on their needs.\n\n\n\n## Execute unit tests\n\nTo compile and run the tests, you need to execute\n\n```sh\n$ mkdir build\n$ cd build\n$ cmake ..\n$ make\n$ ./MultiArrayVariant\n$ ./MultiArrayPoly\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftioneb64%2Fcpp-polymorph-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftioneb64%2Fcpp-polymorph-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftioneb64%2Fcpp-polymorph-class/lists"}