A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/janwilmans/ring_span below:

janwilmans/ring_span: A ring_span implementation that allows zero construction and destruction

Another search for the one ring. Thanks 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().

Usage:

    std::vector<int> v;
    v.resize(256);
    nostd::ring_span rs(v);
    rs.push_back(1);  // 'normal' push_back
    class Foo{ std::vector<int> values; } ;
    std::vector<Foo> v;
    v.resize(16);
    nostd::ring_span rs(v);
    Foo & foo = rs.push_back(); // modify / re-use existing elements without re-construction

features:

restrictions:

The restriction allows the span to be slightly more efficient.

design considerations:

// example added exceptions for error handling
template <typename T>
void safe_push(nostd::ring_span<T> rs, T v)
{
    if (rs.size() == rs.capacity())
    {
        throw std::runtime_error("safe_push exceeds span capacity");
    }
    rs.push_back(v);
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4