{"id":13729848,"url":"https://github.com/nonstd-lite/ring-span-lite","last_synced_at":"2025-11-05T15:03:12.250Z","repository":{"id":53744871,"uuid":"90287195","full_name":"martinmoene/ring-span-lite","owner":"martinmoene","description":"ring-span lite - A C++yy-like ring_span type for C++98, C++11 and later in a single-file header-only library","archived":false,"fork":false,"pushed_at":"2025-03-17T10:22:20.000Z","size":264,"stargazers_count":157,"open_issues_count":7,"forks_count":14,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-31T04:11:41.079Z","etag":null,"topics":["cpp11","cpp14","cpp17","cpp98","header-only","no-dependencies","ring","ring-buffer","ring-span","single-file"],"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/martinmoene.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-05-04T16:50:10.000Z","updated_at":"2025-03-17T10:22:24.000Z","dependencies_parsed_at":"2024-01-14T16:44:15.126Z","dependency_job_id":"42dde23b-f39c-41ce-ba47-1cad8195c1d6","html_url":"https://github.com/martinmoene/ring-span-lite","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fring-span-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fring-span-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fring-span-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fring-span-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinmoene","download_url":"https://codeload.github.com/martinmoene/ring-span-lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788404,"owners_count":21804280,"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":["cpp11","cpp14","cpp17","cpp98","header-only","no-dependencies","ring","ring-buffer","ring-span","single-file"],"created_at":"2024-08-03T02:01:06.107Z","updated_at":"2025-11-05T15:03:12.237Z","avatar_url":"https://github.com/martinmoene.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# ring-span lite: A circular buffer view for C++98 and later\n\n[![Language](https://img.shields.io/badge/C%2B%2B-98/11/14/17-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)  [![License](https://img.shields.io/badge/license-BSL-blue.svg)](https://opensource.org/licenses/BSL-1.0) [![Build Status](https://github.com/martinmoene/ring-span-lite/actions/workflows/ci.yml/badge.svg)](https://github.com/martinmoene/ring-span-lite/actions/workflows/ci.yml) [![Version](https://badge.fury.io/gh/martinmoene%2Fring-span-lite.svg)](https://github.com/martinmoene/ring-span-lite/releases) [![download](https://img.shields.io/badge/latest-download-blue.svg)](https://raw.githubusercontent.com/martinmoene/ring-span-lite/master/include/nonstd/ring_span.hpp) [![Conan](https://img.shields.io/badge/on-conan-blue.svg)](https://conan.io/center/ring-span-lite) [![Vcpkg](https://img.shields.io/badge/on-vcpkg-blue.svg)](https://vcpkg.link/ports/ring-span-lite) [![Try it on wandbox](https://img.shields.io/badge/on-wandbox-blue.svg)](https://wandbox.org/permlink/GHo8T1PIo7TV7eoG) [![Try it on godbolt online](https://img.shields.io/badge/on-godbolt-blue.svg)](https://godbolt.org/z/7n4Byc)\n\n**Contents**\n\n- [Example usage](#example-usage)\n- [In a nutshell](#in-a-nutshell)\n- [Dependencies](#dependencies)\n- [Installation](#installation)\n- [Synopsis](#synopsis)\n- [Reported to work with](#reported-to-work-with)\n- [Building the tests](#building-the-tests)\n- [Other ring_span implementations](#other-ring-span-implementations)\n- [Notes and references](#notes-and-references)\n- [Appendix](#appendix)\n\nExample usage\n-------------\n\n```Cpp\n#include \"nonstd/ring_span.hpp\"\n#include \u003ciostream\u003e\n#include \u003cnumeric\u003e\n\ntemplate\u003c typename T, size_t N \u003e\ninline size_t dim( T (\u0026arr)[N] ) { return N; }\n\ntemplate\u003c typename T, class Popper\u003e\ninline std::ostream \u0026 operator\u003c\u003c( std::ostream \u0026 os, ::nonstd::ring_span\u003cT, Popper\u003e const \u0026 rs )\n{\n    os \u003c\u003c \"[ring_span: \"; std::copy( rs.begin(), rs.end(), std::ostream_iterator\u003cT\u003e(os, \", \") ); return os \u003c\u003c \"]\";\n}\n\nint main()\n{\n    double arr[]   = { 2.0 , 3.0, 5.0, };\n    double coeff[] = { 0.25, 0.5, 0.25 };\n\n    nonstd::ring_span\u003cdouble\u003e buffer( arr, arr + dim(arr), arr, dim(arr) );\n\n    std::cout \u003c\u003c buffer \u003c\u003c \"\\n\";\n\n    // new sample:\n    buffer.push_back( 7.0 );\n\n    std::cout \u003c\u003c buffer \u003c\u003c \"\\n\";\n\n    double result = std::inner_product( buffer.begin(), buffer.end(), coeff, 0.0 );\n\n    std::cout \u003c\u003c \"filter result: \" \u003c\u003c result \u003c\u003c \"\\n\";\n}\n```\n\n### Compile and run\n\n```Text\nprompt\u003e g++ -std=c++98 -Wall -I../include -o 01-filter.exe 01-filter.cpp \u0026\u0026 01-filter.exe\n[ring_span: 2, 3, 5, ]\n[ring_span: 3, 5, 7, ]\nfilter result: 5\n```\n\nOr to run with [Buck](https://buckbuild.com/):\n\n```Text\nprompt\u003e buck run example/:01-filter \n```\n\nIn a nutshell\n-------------\n\n**ring-span lite** is a single-file header-only library to represent a circular buffer view on a container. The library aims to provide a [C++yy-like ring_span]() for use with C++98 and later [1][2]. Its initial code is inspired on the reference implementation by Arthur O'Dwyer [3]. It is my intention to let the interface of this `ring_span` follow the unfolding standard one.\n\nThis library also includes header `\u003cring.hpp\u003e` to provide a data-owning ring buffer.\n\n**Features and properties of ring-span lite** are ease of installation (single header), freedom of dependencies other than the standard library.\n\n**Limitations of ring-span lite** are ... .\n\nLicense\n-------\n\n*ring-span lite* is distributed under the [Boost Software License](LICENSE.txt).\n\nDependencies\n------------\n\n*ring-span lite* has no other dependencies than the [C++ standard library](http://en.cppreference.com/w/cpp/header).\n\nInstallation\n------------\n\n*ring-span lite* is a single-file header-only library. Put `ring_span.hpp` in the [include](include) folder directly into the project source tree or somewhere reachable from your project.\n\nSynopsis\n--------\n\n**Contents**\n\n- [Types in namespace nonstd](#types-in-namespace-nonstd)\n- [Interface of *ring-span lite*](#interface-of-ring-span-lite)\n- [Non-member functions for *ring-span lite*](#non-member-functions-for-ring-span-lite)\n- [Configuration macros](#configuration-macros)\n\n### Types in namespace nonstd\n\n| Purpose |[p0059](http://wg21.link/p0059)| Type | Notes |\n|---------|:-----------------------------:|------|-------|\n| Circular buffer view |\u0026#10003;/\u0026ndash;| template\u003c\u003cbr\u003e\u0026emsp;class T\u003cbr\u003e\u0026emsp;, class Popper = default_popper\u0026lt;T\u003e\u003cbr\u003e\u0026emsp;, bool `CapacityIsPowerOf2` = false\u003cbr\u003e\u003e\u003cbr\u003eclass **ring_span** | See Note 1 below. |\n| Ignore element |\u0026#10003;| template\u003c class T \u003e\u003cbr\u003eclass **null_popper**    | \u0026nbsp; |\n| Return element |\u0026#10003;| template\u003c class T \u003e\u003cbr\u003eclass **default_popper** | \u0026nbsp; |\n| Return element, replace original |\u0026#10003;| template\u003c class T \u003e\u003cbr\u003eclass **copy_popper** | \u0026nbsp; |\n\nNote 1: `CapacityIsPowerOf2` is an extension (`nsrs_CONFIG_STRICT_P0059=0`).With `CapacityIsPowerOf2` being `true`, method `normalize_()` is optimized to use bitwise and instead of modulo division.\n\n### Interface of *ring-span lite*\n\n#### Class `ring_span`\n\n| Kind |[p0059](http://wg21.link/p0059)| Type / Method | Note / Result |\n|-------|:--------------:|-----------------------------|---------------|\n| Various types  |\u0026#10003;| **type**                   |ring_span\u0026lt;T, Popper\\[, CapacityIsPowerOf2\\]\u003e |\n| \u0026nbsp;         |\u0026#10003;| **size_type**              |\u0026nbsp; |\n| Value types    |\u0026#10003;| **value_type**             |\u0026nbsp; |\n| \u0026nbsp;         |\u0026#10003;| **pointer**                |\u0026nbsp; |\n| \u0026nbsp;         |\u0026#10003;| **reference**              |\u0026nbsp; |\n| \u0026nbsp;         |\u0026#10003;| **const_reference**        |\u0026nbsp; |\n| Iterator types |\u0026#10003;| **iterator**               |\u0026nbsp; |\n| \u0026nbsp;         |\u0026#10003;| **const_iterator**         |\u0026nbsp; |\n| \u0026nbsp;         |\u0026ndash; | **reverse_iterator**       |\u0026nbsp; |\n| \u0026nbsp;         |\u0026ndash; | **const_reverse_iterator** |\u0026nbsp; |\n| Construction   |\u0026#10003;| **ring_span**(\u003cbr\u003eIt begin, It end\u003cbr\u003e, Popper popper = Popper() ) noexcept | create empty span of\u003cbr\u003edistance(begin,end) capacity |\n| \u0026nbsp;         |\u0026#10003;| **ring_span**(\u003cbr\u003eIt begin, It end\u003cbr\u003e, It first, size_type size\u003cbr\u003e, Popper popper = Popper() ) noexcept | create partially filled span of\u003cbr\u003edistance(begin,end) capacity,\u003cbr\u003esize elements |\n| \u0026nbsp;         |\u0026#10003;| **ring_span**( ring_span \u0026\u0026 ) | = default (\u003e= C++11) |\n| \u0026nbsp;         |\u0026#10003;| ring_span\u0026 **operator=**( ring_span \u0026\u0026 ) | = default (\u003e= C++11) |\n| \u0026nbsp;         |\u0026#10003;| **ring_span**( ring_span const \u0026 ) | implicitly deleted (\u003e= C++11) |\n| \u0026nbsp;         |\u0026#10003;| ring_span \u0026 **operator=**( ring_span const \u0026 ); | implicitly deleted (\u003e= C++11) |\n| \u0026nbsp;         |\u0026ndash; | **ring_span**( ring_span const \u0026 ) | declared private (\u003c C++11) |\n| \u0026nbsp;         |\u0026ndash; | ring_span \u0026 **operator=**( ring_span const \u0026 ); | declared private (\u003c C++11) |\n| Iteration      |\u0026#10003;| **begin**() noexcept   | iterator |\n| \u0026nbsp;         |\u0026#10003;| **begin**() noexcept   | const_iterator |\n| \u0026nbsp;         |\u0026#10003;| **cbegin**() noexcept  | const_iterator |\n| \u0026nbsp;         |\u0026#10003;| **end**() noexcept     | iterator |\n| \u0026nbsp;         |\u0026#10003;| **end**() noexcept     | const_iterator |\n| \u0026nbsp;         |\u0026#10003;| **cend**() noexcept    | const_iterator |\n| Reverse iter.  |\u0026ndash; | **rbegin**() noexcept  | reverse_iterator |\n| \u0026nbsp;         |\u0026ndash; | **rbegin**() noexcept  | const_reverse_iterator |\n| \u0026nbsp;         |\u0026ndash; | **crbegin**() noexcept | const_reverse_iterator |\n| \u0026nbsp;         |\u0026ndash; | **rend**() noexcept    | reverse_iterator |\n| \u0026nbsp;         |\u0026ndash; | **rend**() noexcept    | const_reverse_iterator |\n| \u0026nbsp;         |\u0026ndash; | **crend**() noexcept   | const_reverse_iterator |\n| Observation    |\u0026#10003;| **empty**() noexcept   | true if empty |\n| \u0026nbsp;         |\u0026#10003;| **full**() noexcept    | true if full |\n| \u0026nbsp;         |\u0026#10003;| **size**() noexcept    | current number of elements |\n| \u0026nbsp;         |\u0026#10003;| **capacity**() noexcept| maximum number of elements |\n| Element access |\u0026#10003;| **front**() noexcept   | reference to element at front |\n| \u0026nbsp;         |\u0026#10003;| **front**() noexcept   | const_reference to element at front |\n| \u0026nbsp;         |\u0026#10003;| **back**() noexcept    | reference to back element at back |\n| \u0026nbsp;         |\u0026#10003;| **back**() noexcept    | const_reference to element at back |\n| \u0026nbsp;         |\u0026ndash; | **operator[]**( size_type idx ) noexcept | reference to element at specified index |\n| \u0026nbsp;         |\u0026ndash; | **operator[]**( size_type idx ) noexcept | const_reference to element at specified index |\n| Elem.extraction|\u0026#10003;| **pop_front**() | Popper::return_type (p0059: auto) |\n| \u0026nbsp;         |\u0026ndash; | **pop_back**()  | Popper::return_type |\n| Elem.insertion|\u0026#10003; | **push_back**( value_type const \u0026 value ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| \u0026nbsp;         |\u0026ndash; | **push_back**( value_type const \u0026 value )     | void; unrestrained (\u003c C++11) |\n| \u0026nbsp;         |\u0026#10003;| **push_back**( value_type \u0026\u0026 value ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| \u0026nbsp;         |\u0026#10003;| **emplace_back**( Args \u0026\u0026... args ) noexcept(\u0026hellip;)| void; restrained (\u003e= C++11) |\n| \u0026nbsp;         |\u0026ndash; | **push_front**( value_type const \u0026 value ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| \u0026nbsp;         |\u0026ndash; | **push_front**( value_type const \u0026 value )    | void; unrestrained (\u003c C++11) |\n| \u0026nbsp;         |\u0026ndash; | **push_front**( value_type \u0026\u0026 value ) noexcept(\u0026hellip;)| void; restrained (\u003e= C++11) |\n| \u0026nbsp;         |\u0026ndash; | **emplace_front**( Args \u0026\u0026... args ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| Swap           |\u0026#10003;| **swap**( ring_span \u0026 rhs ) noexcept | void; |\n\n#### Class `ring_iterator`\n\n| Kind |[p0059](http://wg21.link/p0059)| Type / Method  | Note / Result |\n|-------|:--------------:|------------------------------|---------------|\n| Various types |\u0026#10003;| **type**                         |ring_span\u003c T, Popper \u003e |\n| \u0026nbsp;        |\u0026#10003;| **difference_type**              |\u0026nbsp; |\n| Value types   |\u0026#10003;| **value_type**                   |\u0026nbsp; |\n| \u0026nbsp;        |\u0026#10003;| **pointer**                      |\u0026nbsp; |\n| \u0026nbsp;        |\u0026#10003;| **reference**                    |\u0026nbsp; |\n| Category      |\u0026#10003;| **iterator_category**            |\u0026nbsp; |\n| Construction  |\u0026#10003;| **ring_iterator**()              | = default (\u003e= C++11) |\n| \u0026nbsp;        |\u0026ndash; | **ring_iterator**()              | (\u003c C++11) |\n| Conversion    |\u0026ndash; | **operator ring_iterator\u003c\u0026hellip;,true\u003e**() const noexcept| const ring_iterator |\n| Element access|\u0026#10003;| **operator\\***() const noexcept  |reference |\n| Increment     |\u0026#10003;| **operator++**() noexcept        |ring_iterator\u003c\u0026hellip;\u003e \u0026 |\n| \u0026nbsp;        |\u0026#10003;| **operator++**( int ) noexcept   |ring_iterator\u003c\u0026hellip;\u003e |\n| Decrement     |\u0026#10003;| **operator--**() noexcept        |ring_iterator\u003c\u0026hellip;\u003e \u0026 |\n| \u0026nbsp;        |\u0026#10003;| **operator--**( int ) noexcept   |ring_iterator\u003c\u0026hellip;\u003e |\n| Addition      |\u0026#10003;| **operator+=**( int i ) noexcept |ring_iterator\u003c\u0026hellip;\u003e \u0026 |\n| \u0026nbsp;        |\u0026#10003;| **operator-=**( int i ) noexcept |ring_iterator\u003c\u0026hellip;\u003e \u0026 |\n| Difference    |\u0026ndash; | **operator-**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) | difference_type, Note 1 |\n| Comparison    |\u0026#10003;| **operator==**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) const noexcept |bool, Note 1 |\n| \u0026nbsp;        |\u0026#10003;| **operator!=**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) const noexcept |bool, Note 1 |\n| \u0026nbsp;        |\u0026#10003;| **operator\u003c**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) const noexcept  |bool, Note 1 |\n| \u0026nbsp;        |\u0026#10003;| **operator\u003c=**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) const noexcept |bool, Note 1 |\n| \u0026nbsp;        |\u0026#10003;| **operator\u003e**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) const noexcept  |bool, Note 1 |\n| \u0026nbsp;        |\u0026#10003;| **operator\u003e=**( ring_iterator\u003c\u0026hellip;\u003e const \u0026 rhs ) const noexcept |bool, Note 1 |\n\nNote 1: accepts lhs and rhs of different const-ness.\n\n### Non-member functions for *ring-span lite*\n\n| Kind            |[p0059](http://wg21.link/p0059)| Function | Note / Result |\n|-----------------|:-----------------------------:|----------|--------|\n| Swap            |\u0026ndash;/\u0026#10003;| **swap**( ring_span\u003c\u0026hellip;\u003e \u0026 lhs, ring_span\u003c\u0026hellip;\u003e \u0026 rhs ) |void |\n| Iterator offset |\u0026#10003;| **operator+**( ring_iterator\u003c\u0026hellip;\u003e it, int i ) noexcept | ring_iterator\u003c\u0026hellip;\u003e |\n| \u0026nbsp;          |\u0026ndash; | **operator+**( int i, ring_iterator\u003c\u0026hellip;\u003e it ) noexcept | ring_iterator\u003c\u0026hellip;\u003e |\n| \u0026nbsp;          |\u0026#10003;| **operator-**( ring_iterator\u003c\u0026hellip;\u003e it, int i ) noexcept | ring_iterator\u003c\u0026hellip;\u003e |\n| \u0026nbsp;          |\u0026ndash; | **operator-**( int i, ring_iterator\u003c\u0026hellip;\u003e it ) noexcept | ring_iterator\u003c\u0026hellip;\u003e |\n\nLegenda:\u0026ensp;\u0026ndash; not in proposal\u0026ensp;\u0026middot;\u0026ensp;\u0026#10003; in proposal\u0026ensp;\u0026middot;\u0026ensp;\u0026ndash;/\u0026#10003; not in proposal/in sg14 code\n\n#### Class `ring`\n\n| Kind | Type / Method | Note / Result |\n|------|---------------|---------------|\n| Circular buffer | template\u003c\u003cbr\u003e\u0026emsp;class Container\u003cbr\u003e\u0026emsp;, bool `CapacityIsPowerOf2` = false\u003cbr\u003e\u003e\u003cbr\u003eclass **ring** | See Note 1 below. |\n| Various types  | **size_type**              |\u0026nbsp; |\n| Value types    | **value_type**             |\u0026nbsp; |\n| \u0026nbsp;         | **reference**              |\u0026nbsp; |\n| \u0026nbsp;         | **const_reference**        |\u0026nbsp; |\n| Iterator types | **iterator**               |\u0026nbsp; |\n| \u0026nbsp;         | **const_iterator**         |\u0026nbsp; |\n| \u0026nbsp;         | **reverse_iterator**       |\u0026nbsp; |\n| \u0026nbsp;         | **const_reverse_iterator** |\u0026nbsp; |\n| Construction   | **ring**()                 | create empty ring,\u003cbr\u003eC-array, `std::array` |\n| \u0026nbsp;         | **ring**(size_type size)   | create empty ring of capacity `size`,\u003cbr\u003edynamic container |\n| Iteration      | **begin**() noexcept       | iterator |\n| \u0026nbsp;         | **begin**() noexcept       | const_iterator |\n| \u0026nbsp;         | **cbegin**() noexcept      | const_iterator |\n| \u0026nbsp;         | **end**() noexcept         | iterator |\n| \u0026nbsp;         | **end**() noexcept         | const_iterator |\n| \u0026nbsp;         | **cend**() noexcept        | const_iterator |\n| Reverse iter.  | **rbegin**() noexcept      | reverse_iterator |\n| \u0026nbsp;         | **rbegin**() noexcept      | const_reverse_iterator |\n| \u0026nbsp;         | **crbegin**() noexcept     | const_reverse_iterator |\n| \u0026nbsp;         | **rend**() noexcept        | reverse_iterator |\n| \u0026nbsp;         | **rend**() noexcept        | const_reverse_iterator |\n| \u0026nbsp;         | **crend**() noexcept       | const_reverse_iterator |\n| Observation    | **empty**() noexcept       | true if empty |\n| \u0026nbsp;         | **full**() noexcept        | true if full |\n| \u0026nbsp;         | **size**() noexcept        | current number of elements |\n| \u0026nbsp;         | **capacity**() noexcept    | maximum number of elements |\n| Element access | **front**() noexcept       | reference to element at front |\n| \u0026nbsp;         | **front**() noexcept       | const_reference to element at front |\n| \u0026nbsp;         | **back**() noexcept        | reference to back element at back |\n| \u0026nbsp;         | **back**() noexcept        | const_reference to element at back |\n| Element access | **front**() noexcept       | reference to element at front |\n| \u0026nbsp;         | **front**() noexcept       | const_reference to element at front |\n| \u0026nbsp;         | **back**() noexcept        | reference to back element at back |\n| \u0026nbsp;         | **back**() noexcept        | const_reference to element at back |\n| \u0026nbsp;         | **operator[]**( size_type idx ) noexcept | reference to element at specified index |\n| \u0026nbsp;         | **operator[]**( size_type idx ) noexcept | const_reference to element at specified index |\n| Elem.extraction| **pop_front**() | Popper::return_type |\n| \u0026nbsp;         | **pop_back**()  | Popper::return_type |\n| Elem.insertion|\u0026 **push_back**( value_type const \u0026 value ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| \u0026nbsp;         | **push_back**( value_type const \u0026 value )     | void; unrestrained (\u003c C++11) |\n| \u0026nbsp;         | **push_back**( value_type \u0026\u0026 value ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| \u0026nbsp;         | **emplace_back**( Args \u0026\u0026... args ) noexcept(\u0026hellip;)| void; restrained (\u003e= C++11) |\n| \u0026nbsp;         | **push_front**( value_type const \u0026 value ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| \u0026nbsp;         | **push_front**( value_type const \u0026 value )    | void; unrestrained (\u003c C++11) |\n| \u0026nbsp;         | **push_front**( value_type \u0026\u0026 value ) noexcept(\u0026hellip;)| void; restrained (\u003e= C++11) |\n| \u0026nbsp;         | **emplace_front**( Args \u0026\u0026... args ) noexcept(\u0026hellip;) | void; restrained (\u003e= C++11) |\n| Swap           | **swap**( ring_span \u0026 rhs ) noexcept | void; |\n\nNote 1: `CapacityIsPowerOf2` is an extension (`nsrs_CONFIG_STRICT_P0059=0`).With `CapacityIsPowerOf2` being `true`, method `normalize_()` is optimized to use bitwise and instead of modulo division. Class `default_popper` is used as popper.\n\n### Configuration macros\n\n#### Tweak header\n\nIf the compiler supports [`__has_include()`](https://en.cppreference.com/w/cpp/preprocessor/include), *ring-span lite* supports the [tweak header](https://vector-of-bool.github.io/2020/10/04/lib-configuration.html) mechanism. Provide your *tweak header* as `nonstd/ring_span.tweak.hpp` in a folder in the include-search-path. In the tweak header, provide definitions as documented below, like `#define nsrs_CPLUSPLUS 201103L`.\n\n#### Standard selection macro\n\n\\-D\u003cb\u003ensrs\\_CPLUSPLUS\u003c/b\u003e=199711L  \nDefine this macro to override the auto-detection of the supported C++ standard, if your compiler does not set the `__cpluplus` macro correctly.\n\n#### Select `std::ring_span` or `nonstd::ring_span`\n\nAt default, *ring_span lite* uses `std::ring_span` if it is available and lets you use it via namespace `nonstd`. You can however override this default and explicitly request to use `std::ring_span` or ring_span lite's `nonstd::ring_span` as `nonstd::ring_span` via the following macros.\n\n-D\u003cb\u003ensrs\\_CONFIG\\_SELECT\\_RING\\_SPAN\u003c/b\u003e=nsrs_RING_SPAN_DEFAULT  \nDefine this to `nsrs_RING_SPAN_STD` to select `std::ring_span` as `nonstd::ring_span`. Define this to `nsrs_RING_SPAN_NONSTD` to select `nonstd::ring_span` as `nonstd::ring_span`. Default is undefined, which has the same effect as defining to `nsrs_RING_SPAN_DEFAULT`.\n\n#### Disable extensions\n\n\\-D\u003cb\u003ensrs\\_CONFIG\\_STRICT\\_P0059\u003c/b\u003e=0  \nDefine this to 1 to omit behaviour not present in proposal [p0059](http://wg21.link/p0059). Default is undefined (same effect as 0).\n\n#### Enable popper empty base class optimization\n\n\\-D\u003cb\u003ensrs\\_CONFIG\\_POPPER\\_EMPTY\\_BASE\\_CLASS\u003c/b\u003e=0  \nPoppers are often stateless. To prevent they take up space C++20 attribute `[[no_unique_address]]` is used when available. Another way to prevent up taking space is to make the popper a base class of `class ring_span`. This is what occurs with macro `nsrs_CONFIG_POPPER_EMPTY_BASE_CLASS` defined to 1. This is an extension to proposal p0059. Disabling extensions via macro `nsrs_CONFIG_STRICT_P0059` also disables this extension. Default is undefined (same effect as 0).\n\n#### Enable compilation errors\n\n\\-D\u003cb\u003ensrs\\_CONFIG\\_CONFIRMS\\_COMPILATION\\_ERRORS\u003c/b\u003e=0  \nDefine this to 1 to include the tests with compile-time errors. Default is undefined (same effect as 0).\n\nReported to work with\n---------------------\n\nThe table below mentions the compiler versions *ring-span lite* is reported to work with.\n\nOS        | Compiler   | Versions |\n---------:|:-----------|:---------|\nWindows   | Clang/LLVM | ? |\n\u0026nbsp;    | GCC        | 5.2.0, 6.3.0 |\n\u0026nbsp;    | Visual C++\u003cbr\u003e(Visual Studio)| 8 (2005), 10 (2010), 11 (2012),\u003cbr\u003e12 (2013), 14 (2015, 2017) |\nGNU/Linux | Clang/LLVM | 3.5.0 |\n\u0026nbsp;    | GCC        | 4.8.4 |\nOS X      | ?          | ?   |\n\nBuilding the tests\n------------------\n\nTo build the tests you need:\n- [Buck](https://buckbuild.com/) or [CMake](http://cmake.org) version 2.8.7 or later to be installed and in your PATH.\n- A [suitable compiler](#reported-to-work-with).\n\nThe [*lest* test framework](https://github.com/martinmoene/lest)  is included in the [test folder](test).\n\n### Buck\n\nTo run the tests:\n\n```Text\nprompt\u003e buck run test/\n```\n\n### CMake\n\nThe following steps assume that the [ring-span lite source code](https://github.com/martinmoene/ring-span-lite) has been cloned into a directory named `c:\\ring-span-lite`.\n\n1. Create a directory for the build outputs for a particular architecture.  \nHere we use c:\\ring-span-lite\\build-win-x86-vc10.\n\n        cd c:\\ring-span-lite\n        md build-win-x86-vc10\n        cd build-win-x86-vc10\n\n2. Configure CMake to use the compiler of your choice (run `cmake --help` for a list).\n\n        cmake -G \"Visual Studio 10 2010\" [see 3. below] ..\n\n3. Optional. You can control above configuration through the following options:\n\n   - `-DRING_SPAN_LITE_COLOURISE_TEST=ON`: use colour for pass, fail, default off\n\n4. Build the test suite in the Debug configuration (alternatively use Release).    \n\n        cmake --build . --config Debug\n\n5. Run the test suite.    \n\n        ctest -V -C Debug\n\nAll tests should pass, indicating your platform is supported and you are ready to use *ring-span lite*. See the table with [supported types and functions](#features).\n\nOther ring-span implementations\n-------------------------------\n\n- Bjørn Reese. [Circular span](https://github.com/breese/trial.circular).\n- Jan Wilmans. [ring_span](https://github.com/janwilmans/ring_span), based on code by Björn Fahller.\n\nNotes and references\n--------------------\n\n### References\n\n[1] [p0059: A proposal to add a ring span to the standard library](http://wg21.link/p0059) ([latest](http://wg21.link/p0059), [r4](http://wg21.link/p0059r4), [r3](http://wg21.link/p0059r3), [r2](http://wg21.link/p0059r2), [r1](http://wg21.link/p0059r1), [r0](http://wg21.link/p0059r0)).  \n[2] [WG21-SG14/SG14](https://github.com/WG21-SG14/SG14/). Reference implementation of [`std::ring_span`](https://github.com/WG21-SG14/SG14/blob/master/SG14/ring.h) by [Guy Davidson](https://github.com/hatcat) and [Arthur O'Dwyer](https://github.com/Quuxplusone).  \n[3] [Arthur O'Dwyer](https://github.com/Quuxplusone). Reference implementation of [`std::ring_span`](https://github.com/Quuxplusone/ring_view).  \n[4] Arthur O’Dwyer. [Reference types with metadata cause problems](https://quuxplusone.github.io/blog/2018/05/30/reference-types-with-metadata-cause-problems/). 30 May 2018.  \n[5] Phillip Johnston. [Creating a Circular Buffer in C and C++](https://embeddedartistry.com/blog/2017/4/6/circular-buffers-in-cc). 17 May 2017.  \n[6] Jan Gaspar. [Boost.Circular Buffer](http://www.boost.org/libs/circular_buffer).  \n\nAppendix\n--------\n\n**Contents**\n\n- [A.1 Applets](#a1)\n- [A.2 Compile-time information](#a2)\n- [A.3 Ring-span lite test specification](#a3)\n\n\u003ca id=\"a1\"\u003e\u003c/a\u003e\n### A.1 Applets\n\nApplets demonstrate a specific use case. They are available via tag `[.applet]`.\n\n```Text\n\u003e ring-span-main.t.exe -l .applet\nring_span: filter[.applet]\n```\n\n\u003ca id=\"a2\"\u003e\u003c/a\u003e\n### A.2 Compile-time information\n\nThe version of *ring-span lite* is available via tag `[.version]`. The following tags are available for information on the compiler and on the C++ standard library used: `[.compiler]`, `[.stdc++]`, `[.stdlanguage]` and `[.stdlibrary]`.\n\n\u003ca id=\"a3\"\u003e\u003c/a\u003e\n### A.3 Ring-span lite test specification\n\nNote: test cases that assert are tagged with `[.assert]` and only run when [.assert] is included on the command line, like: `test [.assert] partial-test-name`.\n\n\u003cdetails\u003e\n\u003csummary\u003eclick to expand\u003c/summary\u003e\n\u003cp\u003e\n\n```Text\nring_span: Allows to construct an empty span from an iterator pair\nring_span: Allows to construct an empty span from an iterator pair - capacity is power of 2\nring_span: Allows to construct a partially filled span from an iterator pair and iterator, size\nring_span: Allows to construct a partially filled span from an iterator pair and iterator, size - capacity is power of 2\nring_span: Disallows to copy-construct from a ring_span (compile-time)\nring_span: Disallows to copy-assign from a ring_span (compile-time)\nring_span: Allows to move-construct from a ring_span (C++11)\nring_span: Allows to move-assign from a ring_span (C++11)\nring_span: Allows to obtain the capacity of a span\nring_span: Allows to obtain the number of elements in a span (size)\nring_span: Allows to check for an empty span\nring_span: Allows to check for a full span\nring_span: Allows to observe the element at the specified index [extension]\nring_span: Allows to observe the element at the front\nring_span: Allows to observe the element at the back\nring_span: Allows to obtain and remove the element at the front\nring_span: Allows to obtain and remove the element at the back [extension]\nring_span: Allows to copy-insert an element at the front [extension]\nring_span: Allows to move-insert an element at the front (C++11) [extension]\nring_span: Allows to emplace an element at the front (C++11) [extension]\nring_span: Allows to copy-insert an element at the back\nring_span: Allows to move-insert an element at the back (C++11)\nring_span: Allows to emplace an element at the back (C++11)\nring_span: Adding an element to an empty span makes it non-empty (front) [extension]\nring_span: Adding an element to an empty span makes it non-empty (back)\nring_span: Adding an element to an empty span doesn't change its capacity (front) [extension]\nring_span: Adding an element to an empty span doesn't change its capacity (back)\nring_span: Adding an element to a full span leaves it full (front) [extension]\nring_span: Adding an element to a full span leaves it full (back)\nring_span: Adding an element to a full span doesn't change its capacity (front) [extension]\nring_span: Adding an element to a full span doesn't change its capacity (back)\nring_span: Removing an element from a span with one element makes it empty (front)\nring_span: Removing an element from a span with one element makes it empty (back) [extension]\nring_span: Removing an element from a span with one element doesn't change its capacity (front)\nring_span: Removing an element from a span with one element doesn't change its capacity (back) [extension]\nring_span: Removing an element from a full span makes it not full (front)\nring_span: Removing an element from a full span makes it not full (back) [extension]\nring_span: Removing an element from a full span doesn't change its capacity (front)\nring_span: Removing an element from a full span doesn't change its capacity (back) [extension]\nring_span: Allows to swap spans (member)\nring_span: Allows to swap spans (non-member)\nring_span: Allows to appear in range-for (C++11)\nring_span: Allows iteration (non-const)\nring_span: Allows iteration (const)\nring_span: Allows iteration (mixed const-non-const)\nring_span: Allows reverse iteration (non-const) [extension]\nring_span: Allows reverse iteration (const) [extension]\nring_span: Allows reverse iteration (mixed const-non-const) [extension]\nring_span: A span with capacity zero is both empty and full\nring_span: A full span is a delay-line of capacity elements (back-front)\nring_span: A full span is a delay-line of capacity elements (front-back) [extension]\nring_span: A non-full span is a stack of capacity elements (back) [extension]\nring_span: A non-full span is a stack of capacity elements (front) [extension]\nring_span: A non-full span behaves like an harmonica (back-front)\nring_span: A non-full span behaves like an harmonica (front-back) [extension]\nring_iterator: Allows conversion to const ring_iterator [extension]\nring_iterator: Allows to dereference iterator (operator*())\nring_iterator: Allows to dereference iterator (operator-\u003e())\nring_iterator: Allows to index from iterator (operator[](size_t))\nring_iterator: Allows to increment iterator (prefix)\nring_iterator: Allows to increment iterator (postfix)\nring_iterator: Allows to decrement iterator (prefix)\nring_iterator: Allows to decrement iterator (postfix)\nring_iterator: Allows to advance iterator (+=) [extension]\nring_iterator: Allows to advance iterator (-=) [extension]\nring_iterator: Allows to offset iterator (+) [extension]\nring_iterator: Allows to offset iterator (-) [extension]\nring_iterator: Allows to obtain difference of iterators [extension]\nring_iterator: Allows to compare iterators (==)\nring_iterator: Allows to compare iterators (!=)\nring_iterator: Allows to compare iterators (\u003c)\nring_iterator: Allows to compare iterators (\u003c=)\nring_iterator: Allows to compare iterators (\u003e)\nring_iterator: Allows to compare iterators (\u003e=)\nring_iterator: Allows to compare iterators (mixed const-non-const)\nnull_popper: A null popper returns void\nnull_popper: A null popper leaves the original element unchanged\ndefault_popper: A default popper returns the element\ndefault_popper: A default popper moves the element (C++11)\ndefault_popper: A default popper leaves the original element unchanged\ncopy_popper: A copy popper returns the element\ncopy_popper: A copy popper replaces the original element\nring: Allows to create data owning ring from container\nring: Allows to create data owning ring from container - capacity is power of 2\nring: Allows to create data owning ring from std::array (C++11)\nring: Allows to create data owning ring from C-array\ntweak header: reads tweak header if supported [tweak]\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonstd-lite%2Fring-span-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnonstd-lite%2Fring-span-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonstd-lite%2Fring-span-lite/lists"}