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

Explicit non-consuming transform adaptor preserving reentrancy. More...

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::vis_transform_fn jh::ranges::views::vis_transform {}
 The user-facing vis_transform adaptor.

Detailed Description

Explicit non-consuming transform adaptor preserving reentrancy.

Author
JeongHan-Bae mastr.nosp@m.opse.nosp@m.udo@g.nosp@m.mail.nosp@m..com

The jh::ranges::views::vis_transform adaptor provides an explicit, observation-only variant of std::views::transform. It guarantees non-consuming behavior for reentrant ranges and is used internally by adaptors such as jh::ranges::views::flatten.

Unlike the standard adaptor, which treats every transformation as consumptive, vis_transform ensures that its result remains reentrant and stable whenever the underlying range allows it.

Design rationale

  • Non-consuming by contract: The resulting view never consumes its input.
  • Explicit intent: Because this guarantees reentrancy, its use must be explicit.
  • Interoperability: Fully compatible with jh::ranges::views::common() and jh::ranges::to.

Typical pipeline

A typical usage chain combining multiple adaptors and collection:

auto result = ids
| jh::ranges::views::flatten() // invokes vis_transform internally
constexpr detail::common_fn common
User-facing common adaptor instance.
Definition common.h:270
constexpr detail::zip_pipe_fn zip_pipe
Extended multi-argument zip adaptor for pipe syntax.
Definition zip.h:317
constexpr detail::flatten_fn flatten
User-facing flatten adaptor.
Definition flatten.h:255
constexpr detail::enumerate_fn enumerate
The user-facing enumerate adaptor.
Definition enumerate.h:149
constexpr to_fn< C > to
Global instance of the to adaptor.
Definition to.h:347

This form requires no intermediate collect() adaptor — the pipeline remains reentrant, and to<> performs direct construction.

See also
jh::ranges::vis_transform_view
jh::ranges::views::transform
jh::ranges::views::common
jh::ranges::to
Version
1.3.x
Date
2025