Parma Polyhedra Library requirements
Internal borrowed pointer and embedded-list iterator adapters

Internal borrowed pointer and embedded-list iterator adapters

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
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.

Internal numerical rows need ordinary pointer-range views without transferring element ownership.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Inspect inherited aliases; use noncopyable elements to check exact borrowed identities and a throwing pointer-object fixture to check exception propagation and completed-subobject cleanup.

src/Ptr_Iterator_defs.hh; src/Ptr_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc.

CPP
Internal

Internal source header: Ptr_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to Ptr_Iterator<P>; dependent aliases are its declared iterator types.

template <typename P> class Ptr_Iterator;
typedef typename std::iterator_traits<P>::iterator_category iterator_category;
typedef typename std::iterator_traits<P>::value_type value_type;
typedef typename std::iterator_traits<P>::difference_type difference_type;
typedef typename std::iterator_traits<P>::pointer pointer;
typedef typename std::iterator_traits<P>::reference reference;
SW_SPEC
2
PPL-SPEC-000632
PPL-SPEC-000632
Pointer-position construction, conversion and assignment

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.

Position copying and const conversion must preserve the referent rather than copy the referenced numerical value.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check null equality, explicit binding, independent copies, assignment, const conversion, wrapper moves and destruction; inject underlying pointer construction/copy/assignment exceptions without copying noncopyable elements.

src/Ptr_Iterator_defs.hh; src/Ptr_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc.

CPP
Internal

Internal source header: Ptr_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to Ptr_Iterator<P>; dependent aliases are its declared iterator types.

Ptr_Iterator();
explicit Ptr_Iterator(const P& q);
template <typename Q> Ptr_Iterator(const Ptr_Iterator<Q>& q);
// Ordinary copy/move/assignment and destruction are implicitly declared.
SW_SPEC
3
PPL-SPEC-000633
PPL-SPEC-000633
Pointer-adapter dereference, member selection and indexing

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.

A numerical row view must expose the actual stored entry, with the constness selected by its pointer type.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare addresses from dereference, arrow and all valid positive/negative subscripts against independent array positions; update through mutable views and observe through const views.

src/Ptr_Iterator_defs.hh; src/Ptr_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc.

CPP
Internal

Internal source header: Ptr_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to Ptr_Iterator<P>; dependent aliases are its declared iterator types.

reference operator*() const;
pointer operator->() const;
reference operator[](difference_type m) const;
SW_SPEC
4
PPL-SPEC-000634
PPL-SPEC-000634
Pointer-adapter single-step traversal

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.

Forward and reverse iteration must retain the ordinary prefix/postfix distinction.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check every occupied/one-past position of a finite array in both directions for mutable and const adapters, including returned wrapper identities and preceding postfix positions.

src/Ptr_Iterator_defs.hh; src/Ptr_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc.

CPP
Internal

Internal source header: Ptr_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to Ptr_Iterator<P>; dependent aliases are its declared iterator types.

Ptr_Iterator& operator++();
Ptr_Iterator operator++(int);
Ptr_Iterator& operator--();
Ptr_Iterator operator--(int);
SW_SPEC
5
PPL-SPEC-000635
PPL-SPEC-000635
Pointer-adapter displacement and distance

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.

Random-access row operations need signed coordinate displacement without changing referenced values.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Enumerate every pair of positions including one-past; compare both addition orders, subtraction, compound-return identities and signed distances with independent integer ordinals.

src/Ptr_Iterator_defs.hh; src/Ptr_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc.

CPP
Internal

Internal source header: Ptr_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to Ptr_Iterator<P>; dependent aliases are its declared iterator types.

Ptr_Iterator& operator+=(difference_type m);
Ptr_Iterator& operator-=(difference_type m);
difference_type operator-(const Ptr_Iterator& y) const;
Ptr_Iterator operator+(difference_type m) const;
Ptr_Iterator operator-(difference_type m) const;
template <typename P>
Ptr_Iterator<P> operator+(typename Ptr_Iterator<P>::difference_type m,
                          const Ptr_Iterator<P>& y);
SW_SPEC
6
PPL-SPEC-000636
Pointer-adapter compatible comparisons and mixed distance

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.

Mutable and const views of the same row must agree on coordinate identity, order and signed separation.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

For every pair of array positions, check all six comparisons and free distance in each mutable/const type pairing against ordinal equality/order/difference; include null equality.

src/Ptr_Iterator_defs.hh; src/Ptr_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc.

CPP
Internal

Internal source header: Ptr_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to Ptr_Iterator<P>; dependent aliases are its declared iterator types.

template <typename P, typename Q>
bool operator==(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
template <typename P, typename Q>
bool operator!=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
template <typename P, typename Q>
bool operator<(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
template <typename P, typename Q>
bool operator<=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
template <typename P, typename Q>
bool operator>(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
template <typename P, typename Q>
bool operator>=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
template <typename P, typename Q>
typename Ptr_Iterator<P>::difference_type
operator-(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y);
SW_SPEC
7
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.

Embedded list links and numerical-element ownership are separate; iterator copies must remain views of actual live nodes.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Use a valid ring of noncopyable typed nodes and a sentinel, preserve object addresses across relinking, and verify later traversal follows the new links without adapter ownership effects.

src/EList_Iterator_defs.hh; src/EList_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc. src/Doubly_Linked_Object_defs.hh; src/Doubly_Linked_Object_inlines.hh.

CPP
Internal

Internal source header: EList_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to EList_Iterator<T>; dependent aliases are its declared iterator types.

template <typename T> class EList_Iterator;
SW_SPEC
8
PPL-SPEC-000638
Embedded-list position binding and lifetime

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.

Unbound storage needs an explicit initialization rule, while bound iterator copying must preserve the borrowed node rather than its element value.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Assign default-constructed storage before every read, check pointer-assignment identity, copy and assignment, explicitly null-bound equality, mutable and const node binding, and node survival after adapter destruction.

src/EList_Iterator_defs.hh; src/EList_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc. src/Doubly_Linked_Object_defs.hh; src/Doubly_Linked_Object_inlines.hh.

CPP
Internal

Internal source header: EList_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to EList_Iterator<T>; dependent aliases are its declared iterator types.

EList_Iterator();
explicit EList_Iterator(Doubly_Linked_Object* p);
EList_Iterator& operator=(Doubly_Linked_Object* p);
// Ordinary copying, assignment and destruction are implicitly declared.
SW_SPEC
9
PPL-SPEC-000639
Embedded-list typed element access

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.

Typed embedded-node access must expose the live object and preserve its qualification.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare dereference/arrow addresses with independently held node pointers for mutable and const element types; update values through mutable views and verify const views observe those updates.

src/EList_Iterator_defs.hh; src/EList_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc. src/Doubly_Linked_Object_defs.hh; src/Doubly_Linked_Object_inlines.hh.

CPP
Internal

Internal source header: EList_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to EList_Iterator<T>; dependent aliases are its declared iterator types.

T* operator->();
T& operator*();
SW_SPEC
10
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.

Bidirectional list iteration must distinguish old and updated positions while following the actual embedded links.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check empty, singleton and longer ranges in both directions for mutable and const elements, every prefix return identity and postfix old position, final sentinel positions and nonempty end-to-last retreat.

src/EList_Iterator_defs.hh; src/EList_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc. src/Doubly_Linked_Object_defs.hh; src/Doubly_Linked_Object_inlines.hh.

CPP
Internal

Internal source header: EList_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to EList_Iterator<T>; dependent aliases are its declared iterator types.

EList_Iterator& operator++();
EList_Iterator operator++(int);
EList_Iterator& operator--();
EList_Iterator operator--(int);
SW_SPEC
11
PPL-SPEC-000641
Embedded-list position equality

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.

Position identity depends on the node address rather than its value or current place in the chain.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare copies, distinct nodes, sentinels and explicit null bindings for each element qualification; retain copies across relinking and verify equal identities remain equal.

src/EList_Iterator_defs.hh; src/EList_Iterator_inlines.hh; tests/iteratoradaptersspec1.cc. src/Doubly_Linked_Object_defs.hh; src/Doubly_Linked_Object_inlines.hh.

CPP
Internal

Internal source header: EList_Iterator_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation. Member signatures apply to EList_Iterator<T>; dependent aliases are its declared iterator types.

template <typename T>
bool operator==(const EList_Iterator<T>& x, const EList_Iterator<T>& y);
template <typename T>
bool operator!=(const EList_Iterator<T>& x, const EList_Iterator<T>& y);