Skip to content

Further optimizations for random access/contiguous ranges #17

@foonathan

Description

@foonathan

Similar to the fused operation from #9, there are more optimizations possible for random access and contiguous ranges. It would be neat to have them considered.

For random access ranges, the iterator only needs to store a difference_type together with a virtual function reference at(difference_type n) corresponding to the operator[] overload of the iterator. Any traversal or comparison can then be done by integer operations on the difference type; virtual dispatch is only necessary for operator* and operator==(iterator, sentinel).

For contiguous ranges, the iterator only needs to store a pointer. All operations except operator==(iterator, sentinel) can be done without virtual dispatch. For contiguous common ranges in particular, the any_view::iterator should not have any overhead compared to span::iterator.

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