{"id":26271770,"url":"https://github.com/maipa01/mstd","last_synced_at":"2026-04-27T01:01:45.742Z","repository":{"id":282231819,"uuid":"947590404","full_name":"MAIPA01/mstd","owner":"MAIPA01","description":"mstd (Maipa's Standard Library) is an extension of the C++ standard library, providing additional utility functions, new data types, and helpful templates for type comparisons. It aims to enhance the standard functionality with useful features while maintaining compatibility with modern C++.","archived":false,"fork":false,"pushed_at":"2026-04-26T23:24:55.000Z","size":2682,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-26T23:26:26.545Z","etag":null,"topics":["bsd-3-clause","cpp","cpp-library","cpp20","cross-platform","data-structures","function-type-traits","header-only","macros","macros-cpp","open-source","ordered-map","ordered-set","overflow-detection","standard-library-extension","string-utilities","terminal-utilities","utility-library"],"latest_commit_sha":null,"homepage":"https://maipa01.github.io/mstd/html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MAIPA01.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-12T23:48:12.000Z","updated_at":"2026-04-26T23:23:49.000Z","dependencies_parsed_at":"2025-08-08T14:23:22.133Z","dependency_job_id":"23af7fd8-b964-41de-945a-5b95cc9f5b7d","html_url":"https://github.com/MAIPA01/mstd","commit_stats":null,"previous_names":["maipa01/mstd"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/MAIPA01/mstd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIPA01%2Fmstd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIPA01%2Fmstd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIPA01%2Fmstd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIPA01%2Fmstd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MAIPA01","download_url":"https://codeload.github.com/MAIPA01/mstd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIPA01%2Fmstd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32318417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"ssl_error","status_checked_at":"2026-04-26T23:26:25.802Z","response_time":129,"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":["bsd-3-clause","cpp","cpp-library","cpp20","cross-platform","data-structures","function-type-traits","header-only","macros","macros-cpp","open-source","ordered-map","ordered-set","overflow-detection","standard-library-extension","string-utilities","terminal-utilities","utility-library"],"created_at":"2025-03-14T07:14:39.877Z","updated_at":"2026-04-27T01:01:45.737Z","avatar_url":"https://github.com/MAIPA01.png","language":"C++","readme":"# mstd - Maipa's Standard Library\n\n## About\n\n**mstd** (Maipa's Standard Library) is an extension of the C++ standard library, providing additional utility functions,\nnew data types, and helpful templates for type comparisons. It aims to enhance the standard functionality with useful\nfeatures while maintaining compatibility with modern C++. [DOCS](https://maipa01.github.io/mstd/html \"Documentation\")\n\n## Requirements\n\n- **C++ Standard**: The library is designed for **C++17** and later.\n- **Supported Platforms**: The library is intended to work on **Windows, macOS, and Linux**.\n\n## Options\n\n### Compilation defines options\n\nYou can enable option using `#define option_name` or use cmake `set(option_name ON CACHE BOOL)`\n\n| Cmake option/C++ define Name     | Description                                                  | Default |\n|:---------------------------------|:-------------------------------------------------------------|:-------:|\n| `MSTD_ENABLE_CXX20`              | enables c++20 features                                       |   OFF   |\n| `MSTD_DISABLE_ASSERT_ON_RELEASE` | makes every assert in this library (void)0 on release builds |   OFF   |\n| `MSTD_ENABLE_FOR_EACH_MACROS`    | enables FOR_EACH macros                                      |   OFF   |\n| `MSTD_ENABLE_ENUMS_MACROS`       | enables ENUM macros                                          |   OFF   |\n| `MSTD_ENABLE_CLONE_FUNC_MACROS`  | enables CLONE_FUNC macros                                    |   OFF   |\n| `MSTD_ENABLE_EXTRA_MACROS`       | enables external macros                                      |   OFF   |\n\n### External libraries options\n\nIf you want to use external libraries not installed by project using CPM\n\n| Cmake option Name   | Description                                                                           | Default |\n|:--------------------|:--------------------------------------------------------------------------------------|:-------:|\n| `MSTD_FMT_EXTERNAL` | Enable if you want to use own fmt library (tested and compatible fmt version: 12.1.0) |   OFF   |\n\n### Project developing options\n\nThese options are used while testing or changing code in project\n\n| Cmake option Name          | Description                                        |          Default          |\n|:---------------------------|:---------------------------------------------------|:-------------------------:|\n| `MSTD_BUILD_TESTS`         | Build mstd tests                                   | `${PROJECT_IS_TOP_LEVEL}` |\n| `MSTD_BUILD_COVERAGE`      | Enable coverage reporting                          | `${PROJECT_IS_TOP_LEVEL}` |\n| `MSTD_BUILD_DOCUMENTATION` | Build documentation                                | `${PROJECT_IS_TOP_LEVEL}` |\n| `MSTD_ENABLE_CLANG_TIDY`   | Enables clang-tidy check                           | `${PROJECT_IS_TOP_LEVEL}` |\n| `MSTD_INSTALL`             | Enables installation of this project               | `${PROJECT_IS_TOP_LEVEL}` |\n| `MSTD_INSTALL_TEST`        | This is only to test if installation of mstd works |            OFF            |\n\n## Features\n\n- **Extended String Manipulation**: Additional functions for modifying and handling strings.\n- **Terminal Utilities**: Functions for clearing the terminal and retrieving its dimensions.\n- **New Data Structures**:\n    - `ordered_map`: A map that preserves the insertion order, similar to `vector`.\n    - `ordered_set`: A set that maintains insertion order, like `vector`.\n    - `stable_vector`: A vector with stable indexes\n- **Safe Arithmetic Operations**: Functions for performing arithmetic with overflow detection:\n    - `add_overflow`\n    - `sub_overflow`\n    - `mul_overflow`\n    - `div_overflow`\n- **Type Comparisons for Functions**: Templates that allow comparing function types, treating lambdas and function\n  pointers as equivalent when they share the same signature.\n- **Management Utilities**:\n    - `flags`: A class which represents multiple values of given flag-like enum\n    - `id_manager`: Manager which helps with managing ids\n    - `assert`: Macros for easy defining your own assert\n- **Events**:\n    - `events_handler`: Event handler\n\n## Installation\n\nAfter installing, you can use `find_package(mstd)`.\n\n### Components\n\nYou can also include components `find_pcakage(mstd COMPONENTS comp)`. They work the same way as [Compilation defines options](#compilation-defines-options), but\nthey provide separate components you need to include.\n\n| Component Name       | Option                           | Target Name                |\n|:---------------------|:---------------------------------|:---------------------------|\n| CXX20                | `MSTD_ENABLE_CXX20`              | mstd::CXX20                |\n| NO_ASSERT_ON_RELEASE | `MSTD_DISABLE_ASSERT_ON_RELEASE` | mstd::NO_ASSERT_ON_RELEASE |\n| FOR_EACH_MACROS      | `MSTD_ENABLE_FOR_EACH_MACROS`    | mstd::FOR_EACH_MACROS      |\n| ENUMS_MACROS         | `MSTD_ENABLE_ENUMS_MACROS`       | mstd::ENUMS_MACROS         |\n| CLONE_FUNC_MACROS    | `MSTD_ENABLE_CLONE_FUNC_MACROS`  | mstd::CLONE_FUNC_MACROS    |\n| EXTRA_MACROS         | `MSTD_ENABLE_EXTRA_MACROS`       | mstd::EXTRA_MACROS         |\n\n## Macros\n\nBefore including the `mstd.hpp` or `macros.hpp` header, you can define certain macros to enable specific sets of utility\nfunctions and features within the library.\n\n### Available Macros:\n\n- **MSTD_ENABLE_FOR_EACH_MACROS**: This macro enables access to the `DO_FOR_EACH` macro, which allows you to iterate over\n  multiple elements and apply a function to each element.\n\n  Example usage:\n  ```cpp\n  #define MSTD_ENABLE_FOR_EACH_MACROS\n  #include \u003cmstd/mstd.hpp\u003e\n\n  #define TO_STR(x) #x\n  // Example of DO_FOR_EACH with TO_STR macro\n  DO_FOR_EACH(TO_STR, 1, 2, 3); // Outputs: \"1\" \"2\" \"3\"\n  ```\n\n- **MSTD_ENABLE_ENUMS_MACROS**: This macro enables access to the `ENUM` macro, which allows you to define enums or enum classes\n  along with helper functions such as `to_string()` and `size\u003cEnum\u003e()`.\n\n  Example usage:\n  ```cpp\n  #define MSTD_ENABLE_ENUMS_MACROS\n  #include \u003cmstd/mstd.hpp\u003e\n\n  // Defining an enum using ENUM macro\n  ENUM(Color, Red, Green, Blue);\n\n  // Accessing helper functions generated by ENUM macro\n  std::cout \u003c\u003c to_string(Color::Red) \u003c\u003c std::endl; // Outputs: Red\n  std::cout \u003c\u003c size\u003cColor\u003e() \u003c\u003c std::endl; // Outputs: 3 (the number of elements in the enum)\n  ```\n\n- **MSTD_ENABLE_CLONE_FUNC_MACROS**: This macro enables access to macros that help you define basic cloning functions like\n  `Clone()` and `CloneTo()` for your custom classes. Specifically, it uses the `CloneFuncInClassDefinition` macro to\n  automatically generate the `Clone()` function that returns a pointer to a cloned object.\n\n  Example usage:\n  ```cpp\n  #define MSTD_ENABLE_CLONE_FUNC_MACROS\n  #include \u003cmstd/mstd.hpp\u003e\n\n  // Example of a class with Clone() function returning a pointer using CloneFuncInClassDefinition macro\n  class MyClass {\n  public:\n      int value;\n      MyClass(int val) : value(val) {}\n\n      // Using CloneFuncInClassDefinition to define Clone() method\n      CloneFuncInClassDefinition(MyClass, value)\n  };\n\n  MyClass original(10);\n  MyClass* copy = original.Clone(); // Creates a deep copy of original and returns a pointer\n  std::cout \u003c\u003c \"Cloned value: \" \u003c\u003c copy-\u003evalue \u003c\u003c std::endl; // Outputs: Cloned value: 10\n  ```\n\nTo enable these macros, define them before including `mstd.hpp`:\n\n```cpp\n#define MSTD_ENABLE_FOR_EACH_MACROS\n#define MSTD_ENABLE_ENUMS_MACROS\n#define MSTD_ENABLE_CLONE_FUNC_MACROS\n#include \u003cmstd/mstd.hpp\u003e\n```\n\nYou can enable one or more of these macros depending on your needs.\n\n## Usage Examples\n\n### Ordered Map \u0026 Ordered Set\n\n```cpp\n#include \u003cmstd/mstd.hpp\u003e\n#include \u003ciostream\u003e\n\nusing namespace std;\nusing namespace mstd;\n\nint main() {\n    ordered_map\u003cint, string\u003e om;\n    om[1] = \"first\";\n    om[2] = \"second\";\n    om[3] = \"third\";\n    \n    for (const auto\u0026 [key, value] : om) {\n        cout \u003c\u003c key \u003c\u003c \": \" \u003c\u003c value \u003c\u003c endl;\n    }\n    return 0;\n}\n```\n\n### Overflow Detection\n\n```cpp\n#include \u003cmstd/mstd.hpp\u003e\n#include \u003ciostream\u003e\n\nusing namespace std;\nusing namespace mstd;\n\nint main() {\n    size_t result;\n    if (add_overflow(1, 2, result)) {\n        cout \u003c\u003c \"Overflow occurred!\" \u003c\u003c endl;\n    } else {\n        cout \u003c\u003c \"Result: \" \u003c\u003c result \u003c\u003c endl;\n    }\n    return 0;\n}\n```\n\n### Function Type Comparison\n\n```cpp\n#include \u003cmstd/mstd.hpp\u003e\n#include \u003ciostream\u003e\n\nusing namespace std;\nusing namespace mstd;\n\nint main() {\n    auto lambda = [](string s) -\u003e bool { return !s.empty(); };\n    static_assert(is_same_function_v\u003cdecltype(lambda), bool(*)(string)\u003e);\n    cout \u003c\u003c \"Lambda and function pointer are of the same type!\" \u003c\u003c endl;\n    return 0;\n}\n```\n\n## License\n\nThis project is licensed under the **BSD 3-Clause License with Attribution Requirement**. See the [LICENSE](./LICENSE \"License\")\nfile for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaipa01%2Fmstd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaipa01%2Fmstd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaipa01%2Fmstd/lists"}