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
sequence.h File Reference

Concept and utilities for immutable sequence detection in C++20. More...

#include <iterator>
#include <ranges>
#include <type_traits>
#include "iterator.h"
#include "jh/ranges/range_adaptor.h"

Go to the source code of this file.

Namespaces

namespace  jh::concepts
 Behavioral concept namespace of the JH Toolkit.
namespace  jh::ranges
 Semantic pipeline namespace for JH range operations.

Concepts

concept  jh::concepts::sequence
 Concept that checks whether a type provides at least const (non-destructive) iteration.

Typedefs

template<typename T>
using jh::concepts::sequence_value_t = typename detail::sequence_value_type_impl<T>::type
 Extracts the element type of a sequence.
template<sequence Seq>
using jh::concepts::sequence_difference_t
 Deduce the difference_type used by a sequence after range adaptation.

Functions

template<typename Seq>
 jh::ranges::range_adaptor (Seq &&) -> range_adaptor< Seq >
template<concepts::sequence Seq>
decltype(auto) jh::to_range (Seq &&s)
 Converts a sequence into a usable std::ranges::range object.

Variables

template<typename T>
constexpr bool jh::concepts::is_sequence = sequence<T>
 Compile-time check for sequence compliance.

Detailed Description

Concept and utilities for immutable sequence detection in C++20.

Author
JeongHan-Bae <mastropseudo@gmail.com>

The jh::concepts::sequence module defines a lightweight C++20 concept used to detect types that provide immutable iteration through begin() and end(). It generalizes both STL containers and custom sequence-like objects, providing consistent compile-time recognition and value type extraction.

Design Goals:

  • Provide a uniform interface for detecting iterable containers.
  • Support both STL-style and duck-typed sequences.
  • Rely purely on behavioral matching (no typedef or inheritance required).
  • Ensure const-safe and reference-safe deduction for generic algorithms.
  • Integrate naturally with jh::concepts::iterator_t and iterator concepts.

Key Components

Design Notes

  • Type deduction uses jh::concepts::iterator_t<T>, providing a unified meta-interface for STL and custom containers.
  • All qualifiers (const, volatile, references) are removed before deduction to ensure consistent behavior.
  • Concept validation is purely structural — no explicit typedefs are required.
  • Serves as the foundational layer for the jh::range system and range interoperability across user-defined sequence types.
Version
1.3.x
Date
2025