Parma Polyhedra Library requirements
Internal borrowed pointer and embedded-list iterator adapters
1. Pointer-adapter types and borrowed storage PPL-SPEC-000631

Implementation::Ptr_Iterator<P> shall adapt a stored object of type P without copying, destroying or taking ownership of the elements to which it refers. Its five iterator type aliases shall equal the corresponding std::iterator_traits<P> aliases. Each selected operation shall require its underlying P operations and conversions to be well-formed and to satisfy their own range, lifetime and arithmetic preconditions. The underlying object shall manage any resources of P itself; underlying exceptions shall propagate without being converted into a successful iterator result.

For raw object pointers, the adapter shall borrow live elements of a live array; a one-past position shall be admitted where the corresponding pointer operation admits it. Element access shall require an occupied position. Pointer subtraction and range ordering shall require positions within the same array, with representable differences. The adapter shall impose no library numerical-initialization prerequisite.

PPL-SPEC-000632
2. Pointer-position construction, conversion and assignment PPL-SPEC-000632

Default construction shall value-initialize the stored P object. For a raw pointer this shall yield a null position, usable for copying, assignment and equality without element access or pointer arithmetic. Explicit binding shall copy the supplied underlying pointer value. Ordinary copying and assignment shall retain the same borrowed position. Converting construction from Ptr_Iterator<Q> shall initialize the target pointer from the source pointer when that initialization is supported; raw mutable-to-const conversion shall retain element identity.

Destroying the adapter shall destroy its pointer object, leaving borrowed elements untouched. Failed construction shall release completed pointer subobjects. A failure of an underlying pointer operation shall retain that operation's own permitted state, without a stronger general rollback guarantee. These operations shall follow 🔗 1. Pointer-adapter types and borrowed storage.

PPL-SPEC-000633
3. Pointer-adapter dereference, member selection and indexing PPL-SPEC-000633

At admitted element positions, dereference shall return exactly the reference obtained by dereferencing the stored pointer. Member selection shall return the stored pointer converted to the declared pointer type. Indexing by a valid displacement m shall return the same element reference as underlying indexing by m, including negative displacements that remain in the live array.

Element identity and cv-qualification shall follow P and its traits. In particular, constness of a wrapper holding a mutable raw pointer shall not make its referenced element const; a wrapper of a raw const pointer shall provide const element access. Access shall neither move the stored position nor copy the element. 🔗 1. Pointer-adapter types and borrowed storage shall apply.

PPL-SPEC-000634
4. Pointer-adapter single-step traversal PPL-SPEC-000634

Prefix increment and decrement shall advance or retreat the stored pointer by one admitted position and return a reference to the same wrapper. Postfix forms shall perform the same position change and return an independent wrapper holding the preceding position. Borrowed elements shall remain unchanged. Advancing the last array element to one-past and retreating one-past to the last element shall be admitted for nonempty ranges. Movement outside the underlying pointer's valid range shall remain outside 🔗 1. Pointer-adapter types and borrowed storage.

PPL-SPEC-000635
5. Pointer-adapter displacement and distance PPL-SPEC-000635

For admitted displacements m, adding m on either side of an adapter shall return a new adapter at the underlying pointer plus m; subtracting m shall return one at pointer minus m. Compound displacement shall update the original position and return a reference to that wrapper. Nonmutating forms shall preserve their operand. Member distance between compatible same-type adapters shall equal the signed underlying pointer difference. Zero and negative displacements shall be admitted whenever the resulting position remains valid under 🔗 1. Pointer-adapter types and borrowed storage.

6. Pointer-adapter compatible comparisons and mixed distance PPL-SPEC-000636

Equality, inequality and the four ordering comparisons shall return the corresponding comparison of the stored underlying pointers. The free distance operation shall return their signed difference, converted to the left adapter's difference_type. Compatible mutable/const raw pointer adapters shall compare and subtract without changing either position or the referenced elements. Range ordering and subtraction shall retain the same-array and representability preconditions of 🔗 1. Pointer-adapter types and borrowed storage; equality shall also admit compatible null positions.

7. Embedded-list iterator borrowing and valid linked positions PPL-SPEC-000637

Implementation::EList_Iterator<T> shall hold a borrowed Doubly_Linked_Object position. It shall not copy or own the referenced element, alter its links merely by being copied/destroyed, or require library numerical initialization. Element access shall require the node to be the accessible base subobject of a live object of the corresponding T type, respecting const qualification. Navigation shall require the traversed live links and endpoints to belong to a valid embedded chain. A chain's end sentinel shall be an admitted position for identity comparisons and valid reverse traversal, but not for element access.

A position retained on a live node shall retain node identity across link changes. Later navigation shall follow the node's current valid links. Removing or destroying a node shall not transfer ownership to its iterators; clients shall not access a destroyed referent or navigate invalid links. No standard-library iterator concept beyond the declared operations shall be required of this adapter.

8. Embedded-list position binding and lifetime PPL-SPEC-000638

Default construction shall create an unbound adapter whose position shall be assigned before it is observed, compared, copied or navigated. Destruction or binding by pointer assignment shall be admitted before such initialization. Explicit construction or pointer assignment shall store the supplied node pointer, and pointer assignment shall return a reference to the same wrapper. Copying or assigning a bound adapter shall preserve its node identity independently of later changes to the source wrapper. Explicit null binding shall be admitted for copying and identity comparison, with no element access or navigation.

Adapter destruction shall leave nodes and links untouched. Const element views shall be obtained by binding EList_Iterator<const T> to their node pointers. 🔗 7. Embedded-list iterator borrowing and valid linked positions shall apply.

9. Embedded-list typed element access PPL-SPEC-000639

For an occupied typed node admitted by 🔗 7. Embedded-list iterator borrowing and valid linked positions, member selection shall return the node's T* pointer and dereference shall return the exact referenced T object. These operations shall preserve the position, object identity and embedded links. T may be const; such a view shall provide const object access. A mutable view shall observe and permit the node's ordinary value updates without copying or replacing the node. Sentinels, null pointers, unbound positions and nodes without the required T subobject shall not be dereferenced.

10. Embedded-list bidirectional traversal PPL-SPEC-000640

Prefix increment shall follow the current node's forward link and prefix decrement its backward link, returning a reference to the same wrapper. Postfix forms shall return the preceding position while applying the same movement to the original wrapper. Traversal shall not change any node's value or links. Within a valid list range, the last element shall advance to its sentinel and a nonempty range's sentinel shall retreat to its last element. Empty ranges shall require no traversal; advancing an end sentinel or retreating a range's first element shall not be required as ordinary range operations. 🔗 7. Embedded-list iterator borrowing and valid linked positions shall apply.

11. Embedded-list position equality PPL-SPEC-000641

Two bound adapters with the same T parameter shall compare equal exactly when their stored node pointers are equal; inequality shall be the negation. Copying a position, retaining it across valid relinking, or binding separately to the same sentinel shall preserve equality. Distinct live node pointers shall compare unequal, and two explicitly null-bound positions shall compare equal. Comparisons shall not access node values or links, change the wrappers or own their referents. Uninitialized default-constructed positions shall retain the binding prerequisite of 🔗 8. Embedded-list position binding and lifetime.