{"id":15598009,"url":"https://github.com/ibob/xmem","last_synced_at":"2025-09-20T08:33:24.143Z","repository":{"id":65613720,"uuid":"571890153","full_name":"iboB/xmem","owner":"iboB","description":"An alternative memory and smart pointer library for C++","archived":false,"fork":false,"pushed_at":"2024-11-23T13:49:06.000Z","size":227,"stargazers_count":20,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-01T01:50:22.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iboB.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":"2022-11-29T05:16:54.000Z","updated_at":"2024-12-07T12:41:27.000Z","dependencies_parsed_at":"2023-02-16T22:16:23.079Z","dependency_job_id":null,"html_url":"https://github.com/iboB/xmem","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboB%2Fxmem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboB%2Fxmem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboB%2Fxmem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboB%2Fxmem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iboB","download_url":"https://codeload.github.com/iboB/xmem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233648603,"owners_count":18708225,"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":[],"created_at":"2024-10-03T01:26:04.832Z","updated_at":"2025-09-20T08:33:18.863Z","avatar_url":"https://github.com/iboB.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xmem\n\n[![Standard](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Build](https://github.com/iboB/xmem/actions/workflows/unit-test.yml/badge.svg)](https://github.com/iboB/xmem/actions/workflows/unit-test.yml)\n\nAn alternative implementation of the smart pointers in the standard header `\u003cmemory\u003e` with some additional features.\n\n[Blog post about this library and the motivation behind it.](https://ibob.bg/blog/2023/01/01/tracking-shared-ptr-leaks/)\n\nxmem requires at least C++17.\n\n## xmem vs \u0026lt;memory\u0026gt;\n\n* `unique_ptr`: no known differences\n* `shared_ptr`:\n    * xmem allows the control block type to be set as a template argument, thus allowing various features by control-block-level polymorphism.\n        * Most notably (and the main motivation behind the lib): tracking of strong or weak refs, which allow dealing with `shared_ptr`-based leaks\n        * Non-atomic refcounts which improve performance as long as you only use the pointers in a single thread (implemented in `xmem::local_shared_ptr`)\n    * In the spirit of the deprecated atomic operations on `std::shared_ptr` in C++20, xmem offers no atomic ops on `shared_ptr`. It introduces the class `atomic_shared_ptr_storage` to take care of this need.\n    * The owner (control block) of the pointer is directly accessible as `const void*` through `ptr.owner()` and stronly typed as `const control_block_type*` through `ptr.t_owner()`\n    * There is no constructor through weak ptr, and no `shared_ptr` operation throws an exception (except ones by proxy, on allocation or if constructing the object in `make_shared` throws)\n    * A helper function: `make_shared_ptr` to make a `shared_ptr` from an existing object\n    * A helper function: `make_aliased` to make a `shared_ptr` by aliasing another, but safely returning `nullptr` if the source is null.\n* `weak_ptr`:\n    * Like `shared_ptr` it has the control block as a template argument and offers control block access through `owner` and `t_owner`\n    * The pointer has a boolean interface which means no associated control block and says nothing about whether the pointer has expired or not.\n    * An aliasing constructor like the one in `shared_ptr` is provided\n* Besides `enable_shared_from_this` a non-template alternative is introduced `enable_shared_from` which (in the author's opinion) has a better interface. This is inspired from Boost.SmartPtr.\n* Helper functions\n    * `same_owner` - check whether two shared/weak pointers have the same owner\n    * `no_owner` - check if a weak/shared pointer has no owner\n* Functions from C++20: `make_shared_for_overwrite`, `make_unique_for_overwrite`\n\nThe external functionalities: `make_aliased`, `make_ptr`, `enable_shared_from`, `atomic_shared_ptr_storage`, `same_owner`, `no_owner`, are also available for the applicable `std::` pointers through the header `xmem/std_helpers.hpp` in namespace `xstd`.\n\n## License\n\nThis software is distributed under the MIT Software License.\n\nSee accompanying file LICENSE or copy [here](https://opensource.org/licenses/MIT).\n\nCopyright \u0026copy; 2022-2024 [Borislav Stanimirov](http://github.com/iboB)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibob%2Fxmem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibob%2Fxmem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibob%2Fxmem/lists"}