JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::concepts::sequence Concept Reference

Concept that checks whether a type provides at least const (non-destructive) iteration. More...

#include <jh/conceptual/sequence.h>

Concept definition

template<typename T>
concept sequence = requires(const T &t)
{
{ std::begin(t) } -> input_iterator;
{ std::end(t) };
{ std::begin(t) == std::end(t) } -> std::convertible_to<bool>;
{ std::begin(t) != std::end(t) } -> std::convertible_to<bool>;
}
Concept for readable, comparable single-pass iterators.
Definition iterator.h:468
Concept that checks whether a type provides at least const (non-destructive) iteration.
Definition sequence.h:110

Detailed Description

Concept that checks whether a type provides at least const (non-destructive) iteration.

A type T satisfies jh::concepts::sequence if:

  1. It provides begin() and end() that can be called on a const T&.
  2. The returned iterators satisfy jh::input_iterator.
  3. begin() and end() are comparable for equality and inequality.

The concept requires that iteration be non-destructive — traversing the sequence must not modify or consume its internal state.

The type must support at least const iteration (i.e. traversal through const T&), but may also provide mutable iteration (T&). In other words, a sequence represents any type that can be iterated safely multiple times without state consumption, regardless of whether its elements themselves are mutable.

Template Parameters
TThe candidate type to test for sequence behavior.