cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
<iterator>

Backports related to Standard header <iterator>

// or as part of:

Interfaces

Interfaces defined in this section:

Non-backport interfaces (cxxomfort::fix):

Nonmember <iterator> Accessors

C++11 onward have introduced a number of non-member accessor functions for iterator and container elements in C++. These include global begin/end functions to access arrays, containers and sequences, and a number of accessor functions such as size() that checks for a container, array or sequence's reported size.

Begin / End accessors

begin() / end() : the invocation begin(sequence) returns:

rbegin() / rend() : the invocation rbegin(sequence) returns:

cbegin() / cend() / crbegin() / crend() : they return the const_iterator or const_pointer (or T const*) version of the above.

Container Accessors

C++17 added the following functions:

size() : the invocation size(sequence) returns:

empty() : the invocation empty(sequence) returns:

data() : the invocation data(sequence) returns:

Note
cxxomfort provides size() for objects that define begin and end, such as forward_list. As per cppreference, "Custom overloads of size may be provided for classes and enumerations that do not expose a suitable size() member function, yet can be detected", so these overloads are permitted.

Contiguous Access Iterator Tag

Previous to C++20, cxxomfort defines, but can't use, the iterator tag contiguous_iterator_tag . This is a refinement over random_access_iterator_tag used in newer Standards to point out to iterator types that refer to contiguous memory storage (such as raw pointers).

Because it's not possible to redefine member types in std containers and iterators, at present only the following features in cxxomfort make use of the contiguous_iterator_tag type:

See Also

See also
header/iterator @ cppreference (cppreference)
iterator/begin @ cppreference iterator/end @ cppreference
cxxomfort <iterator> supplements
Member cxxomfort::cxxostd::iterator::cbegin (Seq &&)
Iterator accessor
Member cxxomfort::cxxostd::iterator::cend (Seq &&)
Iterator accessor
Member cxxomfort::fix::cdata (C const &container) -> decltype(container.data())
cdata()
Member cxxomfort::fix::static_prev (It const p) noexcept
static_prev