{"id":23903353,"url":"https://github.com/mik90/wrapped_var","last_synced_at":"2026-06-10T23:31:39.210Z","repository":{"id":163754355,"uuid":"334563271","full_name":"mik90/wrapped_var","owner":"mik90","description":"C++ variable wrapped by a mutex like Rust's std::sync::Mutex","archived":false,"fork":false,"pushed_at":"2021-04-02T21:54:04.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T11:13:58.821Z","etag":null,"topics":["cpp"],"latest_commit_sha":null,"homepage":"","language":"CMake","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/mik90.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":"2021-01-31T03:22:27.000Z","updated_at":"2021-04-02T21:54:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"57190181-b25b-433d-92cb-1ba9ac71ad8b","html_url":"https://github.com/mik90/wrapped_var","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"cpp-best-practices/gui_starter_template","purl":"pkg:github/mik90/wrapped_var","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mik90%2Fwrapped_var","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mik90%2Fwrapped_var/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mik90%2Fwrapped_var/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mik90%2Fwrapped_var/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mik90","download_url":"https://codeload.github.com/mik90/wrapped_var/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mik90%2Fwrapped_var/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34175887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cpp"],"created_at":"2025-01-04T22:54:05.536Z","updated_at":"2026-06-10T23:31:39.205Z","avatar_url":"https://github.com/mik90.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wrapped_var\n![CMake build](https://github.com/mik90/wrapped_var/workflows/CMake/badge.svg)\n\nHeader only mutex variable wrappers like Rust's `std::sync::Mutex` but for C++\n\n### Requirements\n- Requires C++11 or newer\n- Header-only so conan isn't strictly required to pull this in as a dependency. You could just pull down the header.  \n  I haven't uploaded the recipe to bincrafters or anywhere so that's kind of the only option.\n\n### Usage\nCreate a `std::string` and protect it underneath a mutex\n```cpp\nwrapped_var\u003cstd::string\u003e wrapped_string{\"hello there\"};\n```\n\nCreate a `std::vector` and protect it underneath a mutex.\n```cpp\nusing vector_type = std::vector\u003cint\u003e;\nconstexpr vector_type::size_type size = 5;\nconstexpr vector_type::value_type value = 12;\nwrapped_var\u003cvector_type\u003e wrapped_string(size, value);\n```\n\nModify a mutex-protected `std::string`\n```cpp\nwrapped_var\u003cstd::string\u003e wrapped_string{\"modify me\"};\n{\n  auto string_accessor = wrapped_string.get();\n  string_accessor.get_ref() = \"you are modified\";\n}\n\nconst auto const_string_accessor = wrapped_string.get();\nASSERT_EQ(const_string_accessor.get_cref(), \"you are modified\");\n```\n\n### Running unit tests\n- Requires conan\n```sh\ngit clone git@github.com:mik90/wrapped_var.git\nmkdir build \u0026\u0026 cd build\ncmake ..\ncmake --build . --target UnitTest\nctest\n```\n#### Running tests with sanitizers\nConfigure the cmake build for release and enable one of the sanitizer flags.\nRelease is more likely to cause problems than debug (or so I read).\n```sh\n-DCMAKE_BUILD_TYPE=Release -DENABLE_SANITIZER_ADDRESS=ON\n```\n\n### Test packaging with conan\n```sh\nconan test . mik90/testing\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmik90%2Fwrapped_var","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmik90%2Fwrapped_var","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmik90%2Fwrapped_var/lists"}