Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah_stdc++_utils.H File Reference

Iterator and container validation utilities. More...

#include <exception>
#include <stdexcept>
#include <ah-errors.H>
Include dependency graph for ah_stdc++_utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Functions

template<typename Container , typename Iterator >
void Aleph::verify_container_and_iterator (const Container &container, const Iterator &itor)
 Verifies that an iterator belongs to a specific container.
 
template<typename Iterator >
void Aleph::verify_iterators (const Iterator &itor1, const Iterator &itor2)
 Verifies that two iterators belong to the same container.
 
template<typename Container , typename Iterator >
void Aleph::verify_container_and_iterators (const Container &container, const Iterator &itor_container, const Iterator &itor1, const Iterator &itor2)
 Verifies container-iterator relationships with distinctness check.
 
template<typename Container , typename Iterator >
void Aleph::verify_container_and_iterators (const Container &container, const Iterator &itor1, const Iterator &itor2)
 Verifies that two iterators both belong to a specific container.
 

Detailed Description

Iterator and container validation utilities.

This header provides utility functions for validating that iterators belong to specific containers. These are useful for debugging and for implementing robust container operations.

Overview

When working with STL-style iterators, it's often necessary to verify that an iterator is valid for a particular container before performing operations. These utilities provide a consistent way to perform such checks and throw appropriate exceptions on failure.

Iterator Requirements

The iterators used with these functions must provide a verify() method:

  • bool verify(const Container&) - returns true if iterator belongs to container
  • bool verify(const Iterator&) - returns true if both iterators belong to same container

Example Usage

template <typename T>
void insert_range(DynList<T>& dest, Iterator first, Iterator last)
{
// Verify iterators belong to the same source container
verify_iterators(first, last);
// ... perform insertion ...
}
Author
Leandro Rabindranath León

Definition in file ah_stdc++_utils.H.