{"id":21943395,"url":"https://github.com/janwilmans/ring_span","last_synced_at":"2025-04-22T18:47:13.827Z","repository":{"id":75898268,"uuid":"270145902","full_name":"janwilmans/ring_span","owner":"janwilmans","description":"A ring_span implementation that allows zero construction and destruction ","archived":false,"fork":false,"pushed_at":"2020-06-07T22:47:40.000Z","size":137,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T17:41:30.869Z","etag":null,"topics":["cpp23","proposal","span"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janwilmans.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":"2020-06-07T00:32:09.000Z","updated_at":"2024-09-04T14:47:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"60b4218d-5665-4e1d-b439-a5cd29ec907d","html_url":"https://github.com/janwilmans/ring_span","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwilmans%2Fring_span","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwilmans%2Fring_span/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwilmans%2Fring_span/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwilmans%2Fring_span/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janwilmans","download_url":"https://codeload.github.com/janwilmans/ring_span/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250301306,"owners_count":21408145,"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":["cpp23","proposal","span"],"created_at":"2024-11-29T03:29:51.411Z","updated_at":"2025-04-22T18:47:13.812Z","avatar_url":"https://github.com/janwilmans.png","language":"C++","readme":"# ring_span\n\nAnother search for the one ring.\nThanks to Björn Fahller for writing the original code, I modified it to fit my use cases and extended it to make it have 'the usual methods' like capacity() and clear().\n\nUsage:\n\n```\n    std::vector\u003cint\u003e v;\n    v.resize(256);\n    nostd::ring_span rs(v);\n    rs.push_back(1);  // 'normal' push_back\n```\n\n```\n    class Foo{ std::vector\u003cint\u003e values; } ;\n    std::vector\u003cFoo\u003e v;\n    v.resize(16);\n    nostd::ring_span rs(v);\n    Foo \u0026 foo = rs.push_back(); // modify / re-use existing elements without re-construction\n```\n\n\nfeatures:\n\n* mostly constrexpr (with some obvious exceptions)\n* works on top of an existing container of choice, it must have .data() and .size()\n* allows insertion and removal without construction or destruction of contained objects\n* pushing a value beyond the capacity of the span overwrites the oldest value\n\nrestrictions:\n\n* requires to be used on memory area where the size is a power of 2\n\nThe restriction allows the span to be slightly more efficient.\n\ndesign considerations:\n\n* keep the span simple\n* the span overwrites the oldest value if a value is pushed in when its full\n* minimal error handling, if needed it can layered on top, see safe_push\n\n```\n// example added exceptions for error handling\ntemplate \u003ctypename T\u003e\nvoid safe_push(nostd::ring_span\u003cT\u003e rs, T v)\n{\n    if (rs.size() == rs.capacity())\n    {\n        throw std::runtime_error(\"safe_push exceeds span capacity\");\n    }\n    rs.push_back(v);\n}\n```\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanwilmans%2Fring_span","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanwilmans%2Fring_span","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanwilmans%2Fring_span/lists"}