|
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.
|
Unified transform adaptor that dispatches between std::views::transform and jh::ranges::views::vis_transform.
More...
#include "jh/ranges/views/vis_transform.h"Go to the source code of this file.
Namespaces | |
| namespace | jh::ranges |
| Semantic pipeline namespace for JH range operations. | |
| namespace | jh::ranges::views |
| Range view adaptor implementations with explicit semantic control. | |
Variables | |
| constexpr detail::transform_fn | jh::ranges::views::transform {} |
The unified transform adaptor entry point. | |
Unified transform adaptor that dispatches between std::views::transform and jh::ranges::views::vis_transform.
The jh::ranges::views::transform adaptor performs a compile-time semantic dispatch between two transformation behaviors:
jh::ranges::views::vis_transform โ when the pair <R, F> satisfies jh::concepts::vis_function_for, meaning the range is non-consuming and the function is a pure observation (returns non-void). std::views::transform โ otherwise, for standard consumptive transformations that may alter or terminate the underlying stream. std::views::transform treats every projection as consumptive, even when it merely observes elements. This breaks reentrancy and forces intermediate buffering in non-consuming pipelines. R and F are known, so the adaptor can route to vis_transform only when the combination preserves observation semantics. This ensures correctness and efficiency. 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 apply requires both the range and the callable type. This ensures that only non-consuming, pure-observation combinations are elevated to vis_transform, while all others fall back to the standard std::views::transform.1.3.x
2025