{"id":26902544,"url":"https://github.com/lvocanson/some-templated-containers","last_synced_at":"2025-04-01T09:44:00.154Z","repository":{"id":274200652,"uuid":"914563180","full_name":"lvocanson/some-templated-containers","owner":"lvocanson","description":"A header-only C++20 library that enhances the Standard Library with extra container classes and utility functions.","archived":false,"fork":false,"pushed_at":"2025-03-31T15:59:02.000Z","size":47,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T17:03:36.986Z","etag":null,"topics":["cpp20","header-only-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lvocanson.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":"2025-01-09T20:59:28.000Z","updated_at":"2025-03-31T15:59:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"2af0f6ea-d016-480d-af38-bd0961901dee","html_url":"https://github.com/lvocanson/some-templated-containers","commit_stats":null,"previous_names":["lvocanson/some-templated-containers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvocanson%2Fsome-templated-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvocanson%2Fsome-templated-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvocanson%2Fsome-templated-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvocanson%2Fsome-templated-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lvocanson","download_url":"https://codeload.github.com/lvocanson/some-templated-containers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620211,"owners_count":20806718,"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":["cpp20","header-only-library"],"created_at":"2025-04-01T09:43:59.613Z","updated_at":"2025-04-01T09:44:00.135Z","avatar_url":"https://github.com/lvocanson.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# some-templated-containers\r\n\r\n**some-templated-containers** is a **header-only C++20 library** that extends the standard library with additional container and utility features. It provides:\r\n\r\n- A `std::vector` extension for **fast O(1) removal**.\r\n- Three **singleton implementations** (Lazy, Eager, and Explicit).\r\n- **Bitwise and arithmetic operators** for `enum class`.\r\n\r\n## Repository Structure\r\n\r\n| Folder         | Description                                          |\r\n|----------------|------------------------------------------------------|\r\n| `include/stc/` | Header files for the library components.             |\r\n| `src/`         | Inline implementations of the library components.    |\r\n| `examples/`    | Standalone example files demonstrating each feature. |\r\n| `tests/`       | Contains unit tests and the testing framework.       |\r\n\r\n## Features Documentation\r\n\r\n| Name/Link | Include statement | Header | Example |\r\n|-----------|-------------------|--------|---------|\r\n| [Swap Back Array](#swap-back-array) | `#include \u003cstc/swap_back_array.h\u003e`    | [Header][swap_back_array.h]    | [Example][swap_back_array_ex]    |\r\n| [Lazy Singleton](#singletons)       | `#include \u003cstc/lazy_singleton.h\u003e`     | [Header][lazy_singleton.h]     | [Example][lazy_singleton_ex]     |\r\n| [Eager Singleton](#singletons)      | `#include \u003cstc/eager_singleton.h\u003e`    | [Header][eager_singleton.h]    | [Example][eager_singleton_ex]    |\r\n| [Explicit Singleton](#singletons)   | `#include \u003cstc/explicit_singleton.h\u003e` | [Header][explicit_singleton.h] | [Example][explicit_singleton_ex] |\r\n| [Enum Operators](#enum-operators)   | `#include \u003cstc/enum_operators.h\u003e`     | [Header][enum_operators.h]     | [Example][enum_operators_ex]     |\r\n\r\n[swap_back_array.h]: https://github.com/lvocanson/some-templated-containers/blob/main/include/stc/swap_back_array.h\r\n[lazy_singleton.h]: https://github.com/lvocanson/some-templated-containers/blob/main/include/stc/lazy_singleton.h\r\n[eager_singleton.h]: https://github.com/lvocanson/some-templated-containers/blob/main/include/stc/eager_singleton.h\r\n[explicit_singleton.h]: https://github.com/lvocanson/some-templated-containers/blob/main/include/stc/explicit_singleton.h\r\n[enum_operators.h]: https://github.com/lvocanson/some-templated-containers/blob/main/include/stc/enum_operators.h\r\n[swap_back_array_ex]: https://github.com/lvocanson/some-templated-containers/blob/main/examples/swap_back_array_example.cpp\r\n[lazy_singleton_ex]: https://github.com/lvocanson/some-templated-containers/blob/main/examples/lazy_singleton_example.cpp\r\n[eager_singleton_ex]: https://github.com/lvocanson/some-templated-containers/blob/main/examples/eager_singleton_example.cpp\r\n[explicit_singleton_ex]: https://github.com/lvocanson/some-templated-containers/blob/main/examples/explicit_singleton_example.cpp\r\n[enum_operators_ex]: https://github.com/lvocanson/some-templated-containers/blob/main/examples/enum_operators_example.cpp\r\n\r\n### Swap Back Array\r\n\r\nExtends `std::vector` to enable **fast O(1) removal** of an element by swapping it with the last element before deletion.\r\n\r\n\u003e :warning: **Warning**  \r\n\u003e This optimization sacrifices element order.\r\n\r\n\u003e :bulb: **Tip**  \r\n\u003e Ideal for **unordered object lists** that frequently grow and shrink, such as game entities, object pools, or real-time systems.\r\n\r\n### Singletons\r\n\r\nA **singleton** is a design pattern that ensures a class has only one instance and provides a global point of access to it.\r\n\r\nEach variant offers different trade-offs:\r\n\r\n| Variant | Pros | Cons |\r\n|---------|------|------|\r\n| `lazy_singleton`     | - Simple to use.\u003cbr\u003e- Constructed **on first access**, delaying initialization until needed.     | - **Cannot pass arguments** to the constructor.\u003cbr\u003e- Deferred initialization may cause a noticeable delay on first access. |\r\n| `eager_singleton`    | - Constructed **before `main()`**, ensuring immediate availability.                              | - **Cannot pass arguments** to the constructor.\u003cbr\u003e- Subject to the [Static Initialization Order Fiasco (SIOF)][siof].     |\r\n| `explicit_singleton` | - Allows **on-demand construction** with arguments.\u003cbr\u003e- Supports **destruction \u0026 re-creation**. | - Requires **manual instantiation**.\u003cbr\u003e- Slight overhead for tracking.                                                    |\r\n\r\n\u003e :memo: **Recommendation**  \r\n\u003e To fully leverage singleton syntax, it is advised to use the **[CRTP idiom][crtp]**.\r\n\r\n\u003e :bulb: **Info**  \r\n\u003e All singleton instances are **allocated in static memory**, avoiding **heap allocation**.\r\n\r\n[siof]: https://en.cppreference.com/w/cpp/language/siof\r\n[crtp]: https://en.cppreference.com/w/cpp/language/crtp\r\n\r\n### Enum Operators\r\n\r\nThis library extends `enum class` (particularly bit flags) by enabling **seamless bitwise and arithmetic operations**.\r\n\r\n---\r\n\r\n## Building\r\n\r\n- As a header-only library, no compilation is needed for usage.\r\n- Simply add the `include/` folder to your compiler’s include paths.\r\n\r\n---\r\n\r\n## Testing\r\n\r\n- The testing framework is in `tests/`.\r\n- To run tests, compile `tests/main.cpp` with the `TESTS_ENABLED` macro defined along with the specific test file for the component you wish to test (e.g. for swap_back_array, compile both `tests/main.cpp` and `tests/swap_back_array_tests.cpp`).\r\n\r\n---\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Feel free to:\r\n\r\n- Fork the repository\r\n- Open issues\r\n- Submit pull requests with improvements\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flvocanson%2Fsome-templated-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flvocanson%2Fsome-templated-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flvocanson%2Fsome-templated-containers/lists"}