|
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.
|
Range view adaptor implementations with explicit semantic control. More...
Variables | |
| constexpr detail::common_fn | common {} |
User-facing common adaptor instance. | |
| constexpr detail::enumerate_fn | enumerate {} |
| The user-facing enumerate adaptor. | |
| constexpr detail::flatten_fn | flatten {} |
User-facing flatten adaptor. | |
| constexpr detail::transform_fn | transform {} |
The unified transform adaptor entry point. | |
| constexpr detail::vis_transform_fn | vis_transform {} |
The user-facing vis_transform adaptor. | |
| constexpr detail::zip_fn | zip {} |
The user-facing zip adaptor. | |
| constexpr detail::zip_pipe_fn | zip_pipe {} |
| Extended multi-argument zip adaptor for pipe syntax. | |
Range view adaptor implementations with explicit semantic control.
The jh::ranges::views namespace contains the complete implementation of JH Toolkit's range view adaptors.
This layer extends the standard C++ ranges/view model with explicit, engineering-oriented semantics for traversal, projection, and composition. In particular, it distinguishes between consuming and non-consuming behaviors, preserves reentrancy where applicable, and enables structure-aware pipeline construction.
All view adaptors provided by the toolkit are defined here. Any flattened or convenience entry points (such as jh::views) forward directly to this namespace without introducing additional abstraction or behavior.
|
inlineconstexpr |
|
inlineconstexpr |
The user-facing enumerate adaptor.
Provides a unified interface for enumerating a sequence with indices, implemented as a jh::ranges::zip_view combining an index std::views::iota with the given sequence. Supports both direct and pipe syntax:
auto e = jh::ranges::views::enumerate(seq); auto e = seq | jh::ranges::views::enumerate(); The starting index can be optionally specified; defaults to 0 if omitted:
|
inlineconstexpr |
User-facing flatten adaptor.
Provides a unified interface for flattening tuple-like elements within a range. The adaptor is lazy and purely observational: tuple-like elements are wrapped into jh::meta::flatten_proxy objects, while other elements are forwarded unchanged.
Supports both direct and pipe usage forms:
auto v = jh::ranges::views::flatten(range); auto v = range | jh::ranges::views::flatten(); Behavior:
jh::concepts::tuple_like, it is wrapped into jh::meta::flatten_proxy. jh::ranges::views::transform, which automatically preserves the consumption behavior of the input range: std::pair, std::tuple, std::array jh::pod::pair, jh::pod::tuple, jh::pod::array jh::ranges::zip_view element proxies (jh::ranges::zip_reference_proxy) std specialization, it cannot occur accidentally. Therefore, declaring structured binding is considered explicit permission for recursive deconstruction, consistent with jh::concepts::tuple_like.
|
inlineconstexpr |
The unified transform adaptor entry point.
Provides an adaptive interface for transformation within range pipelines. The adaptor performs a deferred semantic inspection of the pair <R, F> to determine whether to use the non-consuming or consumptive transformation path.
Supports both direct and pipe usage forms:
auto v = jh::ranges::views::transform(r, f); auto v = r | jh::ranges::views::transform(f); vis_transform semantics and remain reentrant. All others use std::views::transform to preserve correct consumption semantics.
|
inlineconstexpr |
The user-facing vis_transform adaptor.
Provides an explicit, non-consuming transform adaptor for observation-only projections. Unlike std::views::transform, this adaptor preserves reentrancy whenever possible.
Supports both direct and pipe usage forms:
auto v = jh::ranges::views::vis_transform(r, f); auto v = r | jh::ranges::views::vis_transform(f); The adaptor enforces the concept jh::concepts::vis_function_for<F, R>, which requires that the callable is safely invocable for every element of R and returns a non-void result.
jh::ranges::views::common() and jh::ranges::to for final materialization. jh::ranges::views::common(), a vis_transform-based pipeline can be materialized directly into a container via jh::ranges::to — no intermediate collect() is required.
|
inlineconstexpr |
The user-facing zip adaptor.
Provides a unified interface for zipping multiple sequences into a jh::ranges::zip_view. Supports both direct and pipe syntax:
auto z = jh::ranges::views::zip(a, b); auto z = a | jh::ranges::views::zip(b);
|
inlineconstexpr |
Extended multi-argument zip adaptor for pipe syntax.
Supports:
a | zip_pipe(b, c, d) zip_pipe adaptor resolves the inherent ambiguity of the standard zip adaptor: in C++23, zip(a, b) returns a zip_view, while zip(b) produces a closure. This makes multi-argument pipeline forms (a | zip(b, c)) impossible.The zip_pipe variant explicitly defines a closure-only behavior, enabling expressive and unambiguous syntax:
Conceptually, zip_pipe is not a new feature, but a semantic resolution: it restores closure semantics for multi-argument zip operations while maintaining full compatibility with the C++23 range adaptor model.