{"id":27784540,"url":"https://github.com/giovanni-iannaccone/mix","last_synced_at":"2025-04-30T14:28:39.788Z","repository":{"id":290403683,"uuid":"974342139","full_name":"giovanni-iannaccone/mix","owner":"giovanni-iannaccone","description":"C++ class storing data of unknown different types 🌀","archived":false,"fork":false,"pushed_at":"2025-04-29T16:49:16.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-30T14:28:39.696Z","etag":null,"topics":["c-plus-plus","data-structures","data-type","library","mix"],"latest_commit_sha":null,"homepage":"","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/giovanni-iannaccone.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,"zenodo":null}},"created_at":"2025-04-28T16:17:57.000Z","updated_at":"2025-04-29T16:49:20.000Z","dependencies_parsed_at":"2025-04-30T14:28:39.537Z","dependency_job_id":null,"html_url":"https://github.com/giovanni-iannaccone/mix","commit_stats":null,"previous_names":["giovanni-iannaccone/mix"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanni-iannaccone%2Fmix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanni-iannaccone%2Fmix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanni-iannaccone%2Fmix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovanni-iannaccone%2Fmix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giovanni-iannaccone","download_url":"https://codeload.github.com/giovanni-iannaccone/mix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251721212,"owners_count":21632786,"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","data-structures","data-type","library","mix"],"created_at":"2025-04-30T14:28:36.520Z","updated_at":"2025-04-30T14:28:39.783Z","avatar_url":"https://github.com/giovanni-iannaccone.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌀 Class `mix`\n\nUnlike standard C++ containers like std::vector, which require specifying the type of the stored elements at the time of declaration, the mix class provides a groundbreaking approach. It allows storing objects of unknown or heterogeneous types within a single container, determined dynamically during runtime. This flexibility eliminates the constraints of type homogeneity and opens up new possibilities for dynamic applications, making it highly adaptable for scenarios where types cannot be predetermined.\n\nWith mix, developers can insert elements of any type into the same container without wrapping them into a polymorphic base or using complex type-erasing mechanisms like std::variant or std::any. The class leverages pointers and dynamic type casting to achieve this, while maintaining ease of use and high performance. 🌟\n\n## 🧪 Class Overview\nThe class uses a vector of pointers (`std::vector\u003cvoid*\u003e`) as its base structure, allowing for the storage of heterogeneous data without type constraints.\n\n## 🚀 Key Features\n- **Operators**:\n  - `[]`: Accesses the pointer to an element (equivalent to `\u0026container.at\u003cvoid\u003e()`)\n  - `+=`: Adds elements from another mix container to the current one\n  - `==`: Compares two `mix` objects\n  - `!=`: Checks inequality between two `mix` objects\n  - `+`:  Returns a new `mix` object combining two instances\n\n- **Element Access**:\n  - `at(int index)`: Retrieves the element at the given index, cast to the specified type\n\n- **Insertion and Removal**:\n  - `erase(int index)`: Erases the element at the given position\n  - `find(T const element)`: Finds the index of a specific element\n  - `insert(T element, int index = -1)`: Inserts an element of a generic type at the specified position\n  - `pop_back()`: Removes the last element in the container\n  - `push_back(T element)`: Appends an element to the container\n  - `remove(T const element)`: Removes a specific element\n\n- **Container Management**:\n  - `size()`: Returns the total number of elements\n  - `back() `: Returns a reference to the vector's last element\n  - `capacity()`: Provides the internal vector's capacity\n  - `clear()`: Removes all elements from the container\n  - Iterators: `begin()` and `end()` for seamless iteration\n\n## 💡 How to Use `mix`\n\n### Install using CMake\n```cmake\ncmake_minimum_required(VERSION 3.14)\n\nPROJECT(myproject)\n\n# fetch latest mix\ninclude(FetchContent)\nFetchContent_Declare(\n    mix\n    GIT_REPOSITORY https://github.com/giovanni-iannaccone/mix.git\n)\nFetchContent_MakeAvailable(mix)\n\nadd_executable(myproject main.cpp)\ntarget_link_libraries(myproject mix)\n```\n\n### Include `mix` in your project\n```cpp\n#include \u003cmix/mix.hpp\u003e\n```\n\n### Usage Example\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\n#include \u003cmix/mix.hpp\u003e\n\nint main() {\n    mix container;\n\n    // Insert elements of different types\n    container.insert\u003cint\u003e(42); // Integer\n    container.insert\u003cstd::string\u003e(\"Hello World\"); // String\n\n    // Retrieve elements\n    int intValue = container.at\u003cint\u003e(0);\n    std::string strValue = container.at\u003cstd::string\u003e(1);\n\n    std::cout \u003c\u003c \"Integer: \" \u003c\u003c intValue \u003c\u003c \"\\\\n\";\n    std::cout \u003c\u003c \"String: \" \u003c\u003c strValue \u003c\u003c \"\\\\n\";\n\n    return 0;\n}\n```\n\n# 🧩 Contributing\nWe welcome contributions! Please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch ( using \u003ca href=\"https://medium.com/@abhay.pixolo/naming-conventions-for-git-branches-a-cheatsheet-8549feca2534\"\u003ethis\u003c/a\u003e convention).\n3. Make your changes and commit them with descriptive messages.\n4. Push your changes to your fork.\n5. Create a pull request to the main repository.\n\n### 🍃 Contributors\n\u003ca href=\"https://github.com/giovanni-iannaccone/mix/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=giovanni-iannaccone/mix\"  alt=\"mix Contributors\"/\u003e\n\u003c/a\u003e\n\n## ⚖ License\nThis project is licensed under the GPL-3.0 License. See the LICENSE file for details.\n\n## ⚔ Contact\n- For any inquiries or support, please contact \u003ca href=\"mailto:iannacconegiovanni444@gmail.com\"\u003e iannacconegiovanni444@gmail.com \u003c/a\u003e.\n- Visit my site for more informations about me and my work \u003ca href=\"https://giovanni-iannaccone.gith\nub.io\" target=”_blank” rel=\"noopener noreferrer\"\u003e https://giovanni-iannaccone.github.io \u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiovanni-iannaccone%2Fmix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiovanni-iannaccone%2Fmix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiovanni-iannaccone%2Fmix/lists"}