|
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.
|
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. | |
Concept and utilities for immutable sequence detection in C++20.
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.
jh::concepts::iterator_t and iterator concepts. jh::concepts::sequence — Concept ensuring immutable iteration. jh::concepts::sequence_value_t<T> — Extracts element type via iterator_t. jh::concepts::is_sequence<T> — Compile-time boolean for detection. jh::to_range() — Converts any sequence into a range-compatible object. If the input already models std::ranges::range and is safely movable or copyable, it is forwarded unchanged. Otherwise — for non-movable, non-copyable lvalues — it automatically produces a std::ranges::subrange to preserve reference validity. For non-range sequences, it wraps them in a jh::ranges::range_adaptor. jh::concepts::iterator_t<T>, providing a unified meta-interface for STL and custom containers. const, volatile, references) are removed before deduction to ensure consistent behavior. jh::range system and range interoperability across user-defined sequence types. 1.3.x
2025