Skip to content

Option to disable bound checking in operator[]? #70

@traversc

Description

@traversc

In a benchmark for an application, switching to nonstd::span (instead of passing raw pointer and size) resulted in a 2x performance decrease. This was due to the bound checking line for the bracket operator:

span_EXPECTS( detail::is_positive( idx ) && idx < size() );

The default behavior for std::span is to not do bound checking:

"Returns a reference to the idx-th element of the sequence. The behavior is undefined if idx is out of range (i.e., if it is greater than or equal to size())." https://en.cppreference.com/w/cpp/container/span/operator_at

So I believe that behavior should be mirrored or given as a config option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions